http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=5279&lngWId=3
He just indents more and more; he really needs to clean up his code a bit.
Also, I don't think this is right: cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
I'm pretty sure there's an easier way to clear the screen! :)
Besides that, it's a good starting point, I actually borrowed some of his code a long time ago
It's actually PSC that formats it like that.
ah, I thought he just had a lot of nested stuff...
Also, he has goto's, which make it hardish to read :/
ya he gooned it on the system clear... doing system("cls"); is a lot better...all he did was make it move down a bunch of lines.
If you are looking for some sample code that uses winsock, here is some that I wrote:
#include "winsock2.h"
#include "stdio.h"
#define LISTEN_PORT 54
// INITIALIZE WINSOCK
WSADATA wsadata;
if (WSAStartup (MAKEWORD(2,2), &wsadata) != 0) {
printf("The call to the following function failed: WSAStartup\n");
return FALSE;
}
// CREATE THE SOCKET
SOCKET listensocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (listensocket == INVALID_SOCKET) {
printf("The call to the following function failed: socket\n");
return FALSE;
}
// FILL IN THE ADDRESS STRUCTURE (THE "NAME")
SOCKADDR_IN sockaddr;
sockaddr.sin_family = AF_INET;
sockaddr.sin_addr.s_addr = INADDR_ANY;
sockaddr.sin_port = htons(LISTEN_PORT);
// BIND THE NAME TO THE SOCKET
int nReturn = bind(listensocket, (SOCKADDR*)&sockaddr, sizeof(SOCKADDR));
if (nReturn == SOCKET_ERROR) {
printf("The call to the following function failed: bind\n");
closesocket(listensocket);
return FALSE;
}
// START LISTENING ON THE SOCKET
nReturn = listen(listensocket, SOMAXCONN);
if (nReturn == SOCKET_ERROR) {
printf("The call to the following function failed: listen\n");
closesocket(listensocket);
return FALSE;
}
// CLEAN UP AFTER WINSOCK
closesocket(listensocket);
WSACleanup();
references: www.msdn.microsoft.com
very nice sample code ;D
if you want a tutorial that gives sample code along with it of that quality you might wanna check this out.
www.hal-pc.org/~johnnie2/winsock.html
nice code TheMinistered