Connecting Tech Pros Worldwide Help | Site Map

C++\Winsock - Sending std out messages problem

 
LinkBack Thread Tools Search this Thread
  #1  
Old October 11th, 2008, 06:24 PM
Member
 
Join Date: Aug 2008
Location: South essex, England
Age: 16
Posts: 69
Default C++\Winsock - Sending std out messages problem

Hi,
I've been having trouble recently with sending messages to a client.
The client seems to be recieving the sever output (in the console).
This has completely done me in.

I have noticed it is to do with the buffer size.
For example:
Expand|Select|Wrap|Line Numbers
  1. send(client[i].clientsocket, "-h7-Endlist" , sizeof("-h7-Endlist"), 0); // is the previous send() call
  2. send(client[i].clientsocket, client[id].clientname, sizeof(client[id].clientname), 0);
  3. send(client[i].clientsocket, " signed in.\n" , sizeof(" signed in.\n") , 0);
Would send ' signed in.'.
And when I do somthing like this:
Expand|Select|Wrap|Line Numbers
  1. send(client[i].clientsocket, "-h7-Endlist" , sizeof("-h7-Endlist                                 "), 0); // is the previous send() call
  2.     send(client[i].clientsocket, " Says:\n" , 1000, 0);
  3.     send(client[i].clientsocket, client[id].buf , 1000, 0);
  4.  
Would show something liek:

'beta 6

Adam signed in.'

Where 'beta 6' is displayed in the server console, and strangely gets put into send() function.

Also, this worked perfectly over a LAN connect, but not over a WAN connection.
All required ports are opend and forwarded properly.

Is this my cheesy scripting? or a fixable common error?
Reply
  #2  
Old October 16th, 2008, 08:54 AM
Member
 
Join Date: Aug 2008
Location: South essex, England
Age: 16
Posts: 69
Default

Can someone please help me with this.
Reply
  #3  
Old October 16th, 2008, 09:54 AM
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 5,731
Default

If the data is not getting there it is much more likely to be a connection error than a send error.

How did you connect? Was it successful (i.e. not returned errors or error callbacks)?
What were the return values of your send function calls?
Reply
  #4  
Old October 16th, 2008, 05:32 PM
Member
 
Join Date: Aug 2008
Location: South essex, England
Age: 16
Posts: 69
Default

Thanks for posting,
I never seemed to check for send errors, I see what they return...
Reply
  #5  
Old November 14th, 2008, 11:19 PM
Member
 
Join Date: Aug 2008
Location: South essex, England
Age: 16
Posts: 69
Default

Bit of a bump...
I made a flash client for it as well.
But, its very odd, it displays data that even hasnt been echoed by the server.
So, Most likely a send() error.

What is the best method of using send?
send(socket, "hello", sizeof "hello", 0),
send(socket, string, sizeof string, 0),
send(socket, "hello", 1000, 0),
or send(socket, string, 1000 , 0); ?
Reply
  #6  
Old November 26th, 2008, 09:31 PM
Member
 
Join Date: Aug 2008
Location: South essex, England
Age: 16
Posts: 69
Default

Please?
Could the environment affect its behaviour?
It works fine on local host, just not on another pc...
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.