Pepper
New Member
meep meep...!
Posts: 444
|
Post by Pepper on May 3, 2004 10:24:43 GMT -5
|
|
Alexx
New Member
Posts: 15
|
Post by Alexx on May 3, 2004 12:13:46 GMT -5
mind giving me a basic socket code to connect to a server, ill be fine from there.
|
|
Pepper
New Member
meep meep...!
Posts: 444
|
Post by Pepper on May 3, 2004 14:26:26 GMT -5
void main() { WSADATA WSAData; if (WSAStartup(MAKEWORD(2, 0), &WSAData)) { #ifdef DEBUG printf("WSAstartup error\n"); #endif return; } //create socket
SOCKET mysock; LPHOSTENT lpHostEntry = NULL; SOCKADDR_IN SockAddr; IN_ADDR iaddr; if ((mysock = socket( AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { #ifdef DEBUG printf("socket error\n"); #endif return; }
memset(&SockAddr, 0, sizeof(SockAddr));
SockAddr.sin_family = AF_INET; SockAddr.sin_port = htons(server_port); iaddr.s_addr = inet_addr(server_address);
if (iaddr.s_addr == INADDR_NONE && (lpHostEntry = gethostbyname(server_address)) == NULL) { #ifdef DEBUG printf("error not a falid ip address or hostname\n"); #endif return;
} if (lpHostEntry) //its a hostname SockAddr.sin_addr = *((LPIN_ADDR)*lpHostEntry->h_addr_list); else SockAddr.sin_addr = iaddr; //its a ip address
//connect to it if (connect(mysock, (SOCKADDR *) &SockAddr, sizeof(SockAddr)) != 0) { #ifdef DEBUG printf("Could not connect to host"); #endif return; }
#ifdef DEBUG printf("Connected to ircserver\n"); #endif
And so on, you need to define some stuff tho
|
|
Pepper
New Member
meep meep...!
Posts: 444
|
Post by Pepper on May 3, 2004 14:36:58 GMT -5
oh shush
|
|
Alexx
New Member
Posts: 15
|
Post by Alexx on May 3, 2004 16:59:51 GMT -5
ppfft thats C.
oh well i can change it, i hope.
|
|
Pepper
New Member
meep meep...!
Posts: 444
|
Post by Pepper on May 4, 2004 1:10:23 GMT -5
wooops :x said shush in wrong post o_0
|
|
Pepper
New Member
meep meep...!
Posts: 444
|
Post by Pepper on May 4, 2004 5:46:55 GMT -5
il give you the complete code when i get home
|
|
Alexx
New Member
Posts: 15
|
Post by Alexx on May 4, 2004 10:46:53 GMT -5
its allright i can see where gaps have to be filled in.
|
|