473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

C++\Winsock - Sending std out messages problem

83
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?
Oct 11 '08 #1
5 2191
Adam01
83
Can someone please help me with this.
Oct 16 '08 #2
Banfa
9,065 Expert Mod 8TB
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?
Oct 16 '08 #3
Adam01
83
Thanks for posting,
I never seemed to check for send errors, I see what they return...
Oct 16 '08 #4
Adam01
83
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); ?
Nov 15 '08 #5
Adam01
83
Please?
Could the environment affect its behaviour?
It works fine on local host, just not on another pc...
Nov 26 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dom | last post by:
I'm new to c++. Just started learning it 24 hours ago. Am running into a compile problem. Please, no one waste the effort telling me to google it. I've been researching it for quite a while with no...
5
by: windandwaves | last post by:
Hi Folk I proudly send my emails using John Rhoton's code for sending them directly via winsock. I now want to take this system to the next level and start sending emails with HTML content. ...
1
by: Nadav | last post by:
Hi, Introduction: ************************* I am developing communication infrastructure for a streaming video server, to achieve optimal performance I use IO Completion ports & a thread pool...
3
by: Jefe | last post by:
Hi Guyz well I wanna implement a tcp chat program with C# and winsock, and I know that I should use Asynchronous methods so my windows program won't be blocked, but in my application both clients...
2
by: Mark | last post by:
Hi, I have a VB6 project that uses a winsock control to receive text messages over a UDP connection. It used to work fine. However, when I changed the code to make it more efficient (ie, less...
1
by: raj.rr7 | last post by:
Hi, I am creating a Http client application using winsock, evc++ 4.0 and K- Jam (WIndows Mobile 5) that will get data from Http server. I am using the following code. WSADATA wsaData;...
0
by: danishce | last post by:
Hello All: I am developing a client/server application using vb.net winsock programming. I am sending data to Server and at the same time receive the incoming data from the server. My application...
1
by: danishce | last post by:
I am developing a client/server application using vb.net winsock programming. I am sending data to Server and at the same time receive the incoming data from the server. Everything works fine but...
4
by: imaloner | last post by:
I am posting two threads because I have two different problems, but both have the same background information. Common Background Information: I am trying to rebuild code for a working,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.