Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2006-01

WinSock error 10106

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alexander Todorov

Hello,
I have a two classes that implement TCP / IP client and server. Internally they use a base class which uses sockets to handle communication. In this part of code I get an error :

procedure TTCPClient.Connect;
begin
  FSocket := Socket(AF_INET, SOCK_STREAM, 0); // create socket descriptor
  if (FSocket <= 0) then
    raise Exception.Create(IntToStr(SocketError));
.....
end;

According to Google this is :
WSAEPROVIDERFAILEDINIT 10106 - (Winsock2)

The code itself is OK and is tested heavy under Linux and now I wanted to use it under Windows.

I call TTCPClient.Connect that is supposed to connect to 127.0.0.1:4444. On the server side thare is TTCPServer written in simillar manner.

This error occurs on my development machine, but not on other testing machine. On testing machine the connection between server and client is established.

Does anyone have a clue what is causing the problem ?? I don't think this is a bug, maybe it's some dependency?

machines used:
developer :
Windows XP, SP1 + critical patches
Lazarus 0.9.8, fpc 2.0.0

tester :
Windows XP, SP1, just installed.

linux :
Lazarus 0.9.10, fpc 2.0.0
OS : Debian (don't know exact version)

Reply by email

Ales Katona
to Alexander Todorov
Alexander Todorov wrote 9 lines
procedure TTCPClient.Connect; begin FSocket := Socket(AF_INET, SOCK_STREAM, 0); // create socket descriptor if (FSocket <= 0) then raise Exception.Create(IntToStr(SocketError)); ..... end;

It seems like some Winsock1 vs Winsock2 issue to me. If you use unit "winsock" you're linking to winsock1 (which is old and deprecated). Sadly noone in FPC bothered to change it to winsock2. There are many winsock2 units out there so you might try to use those and see if it happens too.

Windows is full of surprises when it comes to these things. There are even "reintroduced" bugs just to keep backwards compatibility because they f*cked up.

Honestly tho I never got that error. Btw you might want to try LNet ( http://wiki.lazarus.freepascal.org/index.php/LNet ) atleast you can see how I do it and prehraps compary my code with your (you're looking to TLBaseSocket.SetupSocket).

If you figure this out, can you let me know please? It's always a good idea to know possible bugtraps.

Ales

Reply by email

Alexander Todorov
to Ales Katona
Ales Katona wrote 7 lines
Honestly tho I never got that error. Btw you might want to try LNet ( http://wiki.lazarus.freepascal.org/index.php/LNet ) atleast you can see how I do it and prehraps compary my code with your (you're looking to TLBaseSocket.SetupSocket). If you figure this out, can you let me know please? It's always a good idea to know possible bugtraps.

I will check your source to see where might be the difference. Surprisingly this error doesn't happen every time but occasionally.

Reply by email