I think, this would help.
////////////server////////////////
#include<conio.h>
#include<io.h>
#include<stdlib.h>
#include<stdio.h>
#include<winsock2.h>
#include<windows.h>
//WS2_32.Lib required
#define PORTNUM 888;
//server
bool run = true;
DWORD WINAPI ThreadProcCln(void* xx)
{
int ns = *(int*)xx;
char buf[80];
while(1)
{
gets(buf);
send(ns, buf, sizeof(buf), 0);
if(strcmp("exit", buf) == 0)break;
}
run = false;
return 0;
}
DWORD WINAPI ThreadProcSvr(void* xx)
{
int ns = *(int*)xx;
char buf[80];
HANDLE hThreadCln = 0;
ULONG th_id;
while(1)
{
int nbytes = recv(ns, buf, sizeof(buf), 0);
if(!hThreadCln)hThreadCln = CreateThread(0, 0, ThreadProcCln, (void*)&ns, 0, &th_id);
if(!hThreadCln){printf("error on creating thread\n"

;exit(1);}
printf("%s\n", buf);
if(strcmp("exit", buf) == 0)break;
}
run = false;
return 0;
}
int main()
{
WORD wVersionRequested = MAKEWORD( 2, 2 );
WSADATA wsd;
WSAStartup(wVersionRequested, &wsd);
int s, ns;
int nport;
nport = PORTNUM;
nport = htons((u_short)nport);
sockaddr_in svr_addr, cln_addr;
s = socket(AF_INET, SOCK_STREAM, 0);
if((s = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
{
printf("error on calling socket()\n"

;
exit(1);
}
svr_addr.sin_family = AF_INET;
svr_addr.sin_addr.S_un.S_addr = (u_long)INADDR_ANY;
svr_addr.sin_port = nport;
if(bind(s, (const sockaddr*)&svr_addr, sizeof(svr_addr)) == -1)
{
printf("error on calling bind()"

;
exit(1);
}
printf("server ready: %s\n", inet_ntoa(svr_addr.sin_addr));
if(listen(s, 5) == -1)
{
printf("error on calling listen()\n"

;
exit(1);
}
while(1)
{
int addrlen;
addrlen = sizeof(cln_addr);
if((ns = accept(s, (sockaddr*)&cln_addr, &addrlen)) == -1)
{
printf("error on calling accept\n"

;
exit(1);
}
printf("client: %s\n", inet_ntoa(cln_addr.sin_addr));
int nbytes;
char buf[80];
ULONG th_id;
HANDLE hThreadSvr = 0;
hThreadSvr = CreateThread(0, 0, ThreadProcSvr, (void*)&ns, 0, &th_id);
if(!hThreadSvr){printf("error on creating thread"

;exit(1);}
while(run);
close(ns);
close(s);
exit(0);
}
return 0;
}
////////////server////////////////
////////////client////////////////
#include<io.h>
#include<stdio.h>
#include<stdlib.h>
#include<winsock2.h>
#include<windows.h>
#define PORTNUM 888
#include<windows.h>
bool run = true;
DWORD WINAPI ThreadProcToSvr(void* xx)
{
int ns = *(int*)xx;
char buf[80];
while(1)
{
int nbytes = recv(ns, buf, sizeof(buf), 0);
printf("%s\n", buf);
if(strcmp("exit", buf) == 0)break;
}
run = false;
return 0;
}
DWORD WINAPI ThreadProcCln(void* xx)
{
int ns = *(int*)xx;
char buf[80];
HANDLE hThreadCln = 0;
ULONG th_id;
while(1)
{
gets(buf);
send(ns, buf, sizeof(buf), 0);
if(!hThreadCln)hThreadCln = CreateThread(0, 0, ThreadProcToSvr, (void*)&ns, 0, &th_id);
if(!hThreadCln){printf("error on creating thread\n"

;exit(1);}
if(strcmp("exit", buf) == 0)break;
}
run = false;
return 0;
}
int main(HINSTANCE, HINSTANCE, LPSTR, int)
{
WORD wVersionRequested = MAKEWORD( 2, 2 );
WSADATA wsd;
WSAStartup(wVersionRequested, &wsd);
int s;//SOCKET
sockaddr_in svr_addr;//sei-filipski
hostent *hp;
char buf[80] = "salut la toti";
if((hp = gethostbyname("icurici"

) == 0)
{
printf("error on calling gethostbyname()\n"

;
exit(1);
}
strncpy((char*)&svr_addr.sin_addr.S_un.S_un_b, hp->h_addr_list[0], hp->h_length);
svr_addr.sin_family = hp->h_addrtype;
svr_addr.sin_port = htons((u_short)PORTNUM);
if((s = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
printf("error on creating socket\n"

;
exit(1);
}
if(connect(s, (const sockaddr*)&svr_addr, sizeof(svr_addr)) == -1)
{
printf("error on calling connect()\n"

;
exit(1);
}
ULONG th_id;
HANDLE hThreadSvr = 0;
hThreadSvr = CreateThread(0, 0, ThreadProcCln, (void*)&s, 0, &th_id);
if(!hThreadSvr){printf("error on creating thread"

;exit(1);}
while(run);
close(s);
return 0;
}
////////////client////////////////
Ion Filipski
ICQ: 95034075
AIM: IonFilipski
filipski@excite.com