![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2006
Posts: 22
Rep Power: 0
![]() |
help with displaying message
hi, im trying to learn how to use winsock in C++ programs so ive tried to make a small client/server thing where the client sends a message and the server responds. My problem is that, although they are connecting, and i think they are probably recieving the messages, i cant get the recieved message to be displayed on the console window.
send(sockfd, *ping, 4, 0);
if(errno == -1)
{
cout <<"Send failed!" << endl;
}
else
cout <<"Client> " << *ping << endl;
recv(sockfd, *buf, 256, 0);
if(errno == -1)
{
cout <<"Recv failed!" << endl;
}
else
cout <<"Server> " << *buf << endl; recv(new_sockfd, *buf, 256, 0);
if(errno == -1)
{
cout <<"failed to recieve" << endl;
}
else
cout <<"Client> " << *buf << endl;
send(new_sockfd, *pong, 4, 0);
if(errno == -1)
{
cout <<"Failed to send msg!" << endl;
}
else
cout <<"Server> " << *pong << endl;Client OUTPUT: Client> ping Server> (some wierd stuff that im not gonna bother to write) Server OUTPUT: Client> (blank) Server> pong HAYELLP!!! |
|
|
|
|
|
#2 |
|
Hobbyist
Join Date: Sep 2005
Posts: 261
Rep Power: 4
![]() |
You should show how 'ping', 'pong', and 'buf' are declared. The dereferencing you're doing doesn't look right, but it depends on what 'buf' ect is to say what is right.
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jan 2006
Posts: 22
Rep Power: 0
![]() |
yeah, long after i posted i thought i shoulda probably done that, but i fixed it anyway. I had to change the type i was using from char* to char. I still have a little odd output but i should be able to fix that. ty
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|