   C++ - Problem with blocking sockets
  Hi,I''ve recently started to learn socket programming and have so far managed to make a 2 way chat program to work, though now I''m trying to expand that to multiple connections. I have tried to use:mySock.setBlocking(false);where mySock is the name of the socket - yet I get the following error:error C2228: left of ''.setBlocking'' must have class/struct/union typedoes anyone know what causes this? 
  The ''thing'' that is referenced before the ''.'' operator has to be a struct, class or union because the ''.'' accesses members of said objects.My guess would be that mySock is none of the above n-titties.   "Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan ;  the object "mySock" is of type SOCKET (imported by either Winsock.h or socket.h) ;  SOCKET is not a class/struct/union. In winsock, it is merely a typedef:typedef u_int SOCKET;  You''ll have to make your own wrapper class or use an existing one to get the functionality and interface you want. Internally, the setBlocking() method will use ioctlsocket() to make a socket non-blocking. ;  thanks a lot for your help - your suggestion about ioctlsocket worked fine ;quote:Original post by jermz  SOCKET is not a class/struct/union. In winsock, it is merely a typedef:typedef u_int SOCKET;   You''ll have to make your own wrapper class or use an existing one to get the functionality and interface you want. Internally, the setBlocking() method will use ioctlsocket() to make a socket non-blocking.   Ss it the same in linux? ;quote:Original post by shadowstryker  error C2228: left of ''.setBlocking'' must have class/struct/union typedoes anyone know what causes this?   What the guys above said (Assuming you''re using MSVC) When you set the cursor on the error, and press F1.. what does it say? anything usefull?And if you''re going to code your own socket wrapper - it can be a good idea to look into MFC sockets. Maybe copy/paste some of it  (never saw a copyright here ) ;  what I did for a wrapper is more or less what I always do to determine between different compilers.Since I only develop for Win32 / Linux and not MAC, etc I use:#ifdef WIN32  #include <winsock.h>#else..etcclosing it with a #endifand I do the same for all WSA commands.At the minute it appears my non-blocking sockets are working as expected - I just need to get round to finishing my code as teh dynamic socket handler always creates a new listening socket as soon as one has connected and then manages to connect to itself and soon fills up as many ports as it can (sounds like a DoS!!)...luckily this is just a simple fix :D ;  Hi Shadow,I am also trying to learn winsock, to make a tcp chat and am stuck. Just wondering if you can help. I have managed to make a one way single message program but need to expand this to an n way multiple message one. You said you have the 2 way chat working. The problems im having are:- my program doesnt like spaces in its message, it only prints the first word.- im not sure how to be able to send/receive more than one message.Im not too good at programming so if anyone can point me in the right direction I would be very greatful.ThanksC0UNT Z3R0 ;quote:Original post by Zoot  Ss it the same in linux?   There is no SOCKET typedef, you use unsigned ints, most often.