Delphi/FPC: Port Windows WinSock-based Socket classes to Mac

This project received 2 bids from talented freelancers with an average bid price of $630 USD.

Get free quotes for a project like this
Project Budget
$30 - $250 USD
Total Bids
Project Description

Port existing Windows Sockets-based Pascal language classes library to Mac OS (Delphi or Lazarus programming environment). Need support for both TCP and UDP protocols (SOCK_STREAM/SOCK_DGRAM), blocking and non-blocking sockets; don't using Indy. Non blocking sockets should not use separate thread per each socket.

Classes to port:

//private fields/methods are omitted

------------------- >8 ----------------------------



TIPSocketOnAccept = procedure (socket:TIPSocket);

TIPSocketOnConnecting = TIPSocketOnAccept;

TIPSocketOnRead = TIPSocketOnAccept;

TIPSocketOnConnect = TIPSocketOnAccept;

//base class for TCP/UDP sockets

TIPSocket = class


property Addr:sockaddr_in read GetAddr write FAddr;

property Host:string read GetHost write SetHost;

property Address:string read GetAddress write SetAddress;

property Port:integer read GetPort write SetPort;

property RemoteIP:string read GetRemoteIp;

property Error:cardinal read FError;

property Socket:TSocket read FSocket;

function NoAddr:boolean; // true if address/port is not set

constructor Create(const asynchronous:boolean = true);

destructor Destroy;override;

function EnableAsync:boolean;virtual; //enable non-blocking mode

function DisableAsync:boolean;virtual; //disable non-blocking mode

function Send(data:pointer; cb:cardinal):integer;virtual;abstract;

function Rece(data:pointer; cb:cardinal):integer;virtual;abstract;

procedure Close;

function BytesReceived:cardinal;

procedure SendReadSignal; // for non-blocking sockets sends FD_READ event to enforce reading data from the non-blocking socket.

class function GetRemoteComputerName(ip:ansistring):string; static;

class function ResolveHostName(s:ansistring):ansistring; static;

class function StrToAddr(s:ansistring):integer;static;

class function Select(nfds:Integer; readFDS, writeFDS, exceptFDS:PFDSet; timeout:PTimeVal):integer;


TTCPSocket = class(TIPSocket)



property OnRead:TIPSocketOnRead read FOnRead write FOnRead;

property OnClose:TIPSocketOnRead read FOnClose write FOnClose;

constructor Create(const asynchronous:boolean = true; const basesock:TSocket = -1);

function EnableAsync:boolean;override;

function Connect:boolean;virtual;

function Send(data:pointer; cb:cardinal):integer;override;

function Rece(data:pointer; cb:cardinal):integer;override;

function SendBlock(data:pointer; cb:cardinal; const asynctimeout:integer = -1):integer;virtual; //sends long blocks (more than IO buffer size)

function ReceBlock(data:pointer; cb:cardinal; const asynctimeout:integer = -1):integer;virtual; //receives long blocks (more than IO buffer size)


TTCPServerSocket = class(TTCPSocket)



property OnAccept:TIPSocketOnAccept read FOnAccept write FOnAccept;

property Error:cardinal read FError;

constructor Create(port:integer; const bindaddress:integer = INADDR_ANY; const asynchronous:boolean = true);

function Listen:integer;

function Accept:TTCPSocket;

function EnableAsync:boolean;override;


TUDPSocket = class(TIPSocket)



constructor Create(const asynchronous:boolean = true);

property OnRead:TIPSocketOnRead read FOnRead write FOnRead;

function Broadcast(enable:boolean):boolean; //enables UDP Broadcast

function MulticastTTL(value:integer):boolean;

function Multicast(address:ansistring):boolean; //enables multicast for the specified address, adds itself to Multicast group

function Send(data:pointer; cb:cardinal; _toaddr:integer; _toport:word):integer;

function Rece(data:pointer; cb:cardinal; fromaddr:pinteger; fromport:pword):integer;

function EnableAsync:boolean;override;


TUDPServerSocket = class(TUDPSocket)



constructor Create(port:integer; const bindaddress:integer = INADDR_ANY; const asynchronous:boolean = true);


Skills Required

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online