Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 Jun : connect() error in a thread
| Subject: | connect() error in a thread |
| Posted by: | "jake_blaster" (jake_blast..@ubbi.com.br) |
| Date: | Thu, 16 Jun 2005 09:59:39 |
Hello ppl,
Im having a problem while trying to open a socket connection through a
thread. I've tried a single address and also a local server, but I can't
connect on it. This is the proc Execute from my thread. The "serverport" is
set to 80 and "serverīp" is set to "127.0.0.1" and I tried as "0.0.0.0" too,
but got cres = socket_error... see below.
procedure xTClient.Execute;
var addr : sockaddr_in; cres : integer;
begin
// conecta no server fornecido
addr.sin_family := af_inet;
addr.sin_port := htons(serverport);
addr.sin_addr.S_addr := inet_addr(@serverip);
fillchar(addr.sin_zero,8,0);
clientsock := socket(af_inet, sock_stream, ipproto_tcp);
if clientsock = invalid_socket then begin
log('REMOTE: Error on socket()');
exit;
end;
failedToConnect := false;
cres := connect(clientsock, addr, sizeof(addr));
if cres = socket_error then begin
log('REMOTE: Error on connect()');
bridgeOnline := true;
failedToConnect := true;
closesocket(serversock);
exit;
end;