Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running sockets in binary mode. 1

Status
Not open for further replies.

bradius

Programmer
Apr 30, 2003
3
0
0
GB
I have a class that uses the WinSock socket API and I need to make sure that the socket is using binary mode rather than text.

Any Ideas?

Thanks,
Brad.

Bradius
C++/Java programmer
 
THere is no such thing as "binary mode" and "text mode" on sockets. All data is just a stream of 'octets' (what we call bytes.)

Thus, if you call this function:

[tt]char sz[256] = "ONE\nTWO";
send(
theSocket, // socket descriptor
sz, // address of string
strlen(sz)+1, // length of string plus null terminator
0);[/tt]

The data passed across the network (excluding the TCP headers) will be:

4F 4E 45 0A 54 57 4F 00

As you can see, there was no translation of the newline to a CRLF pair.

I REALLY hope this helps.
Will
 
Thanks very much Will. I guess windows sockets only ever transfer in binary mode (as I suppose "byte stream" is another way of saying "binary").

Your post has been very helpfull.

Bradius
C++/Java programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top