Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 8th, 2006, 10:05 AM   #1
d_heyzie
Newbie
 
Join Date: Jan 2006
Posts: 22
Rep Power: 0 d_heyzie is on a distinguished road
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;
(Section of Client code where i believe the problem lies)

   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;
(Section of Server code where i believe the problem lies)

Client OUTPUT:
Client> ping
Server> (some wierd stuff that im not gonna bother to write)

Server OUTPUT:
Client> (blank)
Server> pong

HAYELLP!!!
d_heyzie is offline   Reply With Quote
Old Jul 8th, 2006, 10:55 AM   #2
Cache
Hobbyist
 
Join Date: Sep 2005
Posts: 261
Rep Power: 4 Cache is on a distinguished road
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.
Cache is offline   Reply With Quote
Old Jul 8th, 2006, 7:36 PM   #3
d_heyzie
Newbie
 
Join Date: Jan 2006
Posts: 22
Rep Power: 0 d_heyzie is on a distinguished road
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
d_heyzie is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:20 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC