Problems with TCP/IP

Hello, this is my second post so please bare with me.......
I have made a server and a client that can send messages over UDP with DGRAM, but now i want to use TCP and 'SOCK_STREAM' (i think) but when i change it, the server wont display a message from the client. It shows that a client sent the message and that the server accepted it but it shows nothing.
here is the server code with UDP and DGRAM

void startServer(int PortNo)
{
char recvBuff[1024];
char sndBuff[]= "Hello\n";
WSADATA wsadata;
error=WSAStartup(0x0202, &wsadata);
if (error)
{
cout << "Error occured on step 1";
system("pause");
}
if (wsadata.wVersion != 0x0202)
{
WSACleanup();
system("echo Error occured on step two");
system("pause");
}


char ServerName[30];
gethostname(ServerName,30);
cout << "(Server) " << ServerName << " is started on port " << PortNo;

SOCKADDR_IN Server;

Server.sin_family = AF_INET;
Server.sin_port = htons (PortNo);
Server.sin_addr.s_addr = inet_addr ("0.0.0.0");
s = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (s == INVALID_SOCKET)
{
cout << "Error occured on step 'TARGET'";
system("pause");
}
if (bind(s, (SOCKADDR *)&Server, sizeof(Server)) == SOCKET_ERROR)
{
cout << "Error Binding" << endl;
system("pause");
}

cout << endl << "Waiting for client response" << endl << endl;

start:;

listen(s,2);
accept(s,NULL,NULL);

SOCKADDR_IN saClient;
int nLen = sizeof(SOCKADDR);

memset(recvBuff, 0, sizeof(recvBuff));
int nRet = recv(s,recvBuff,1024,0);


cout << "Client said: ";
cout << recvBuff << endl;
goto start;

closesocket(s);
return;
}
Topic archived. No new replies allowed.