mira el articulo Windows Sockets: Sequence of Operations en las msdn
resumen:
Server Client
// construct a socket
CSocket sockSrvr;
// construct a socket
CSocket sockClient;
// create the SOCKET
sockSrvr.Create(nPort);1,2
// create the SOCKET
sockClient.Create( );2
// start listening
sockSrvr.Listen( );
// seek a connection
sockClient.Connect(strAddr, nPort);3,4
// construct a new, empty socket
CSocket sockRecv;
// accept connection
sockSrvr.Accept( sockRecv ); 5
// construct file object
CSocketFile file(&sockRecv);
// construct file object
CSocketFile file(&sockClient);
// construct an archive
CArchive arIn(&file,
CArchive::load);
-or-
CArchive arOut(&file,
CArchive::store);
– or Both –
// construct an archive
CArchive arIn(&file,
CArchive::load);
-or-
CArchive arOut(&file,
CArchive::store);
– or Both –
// use the archive to pass data:
arIn >> dwValue;
-or-
arOut << dwValue;6
// use the archive to pass data:
arIn >> dwValue;
-or-
arOut << dwValue;6