fpConnect always returns 0 lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Aidex · 2019-01-24 18:52 Hi! I try to connect to a server via socket and fpConnect(). But fpConnect() always results zero. In case of an error, fpConnect should return -1, but it is zero. And zero is not a valid handle. SocketError is also zero. I'm using Lazarus 1.8.4 on Windows 7 64. Does anyone know any advice? Thank you! uses sockets, resolve; var   ip4: resolve.THostAddr;   Port: Word;   addr: SockAddr;   SocketHandle, ConnHandle: LongInt; begin   [ ... defining ip4 and Port ... ]   SocketHandle := fpSocket(AF_INET,SOCK_STREAM,0);   if SocketHandle=-1 then Exit(false);   initialize(addr);   addr.sin_family := AF_INET;   addr.sin_port := htons(Port);   addr.sin_addr.s_addr := htonl(ip4.s_addr);   ConnHandle := fpConnect(SocketHandle,@addr,SizeOf(addr));   ... => ConnHandle==0 and SocketError==0 ---------------------------------------------------------------------- engkin · 2019-01-24 19:33 "The fpConnect function returns zero if the call was successfull, -1 in case of error." ---------------------------------------------------------------------- Aidex · 2019-01-24 23:18 My best thanks, I'm very embarrassed. I had convinced myself that fpConnect would return a new handle, just like fpAccept. But instead I just have to continue using the SocketHandle. So simple. Now it works. Thanks a lot!