Re: socket programming
From: J. Peter Mugaas (oma00215_at_mail.wvnet.edu)
Date: 02/15/04
- Next message: Jeff Louie: "Re: Interfaces"
- Previous message: William Ryan eMVP: "Re: How to find reliable offshore (India) programming shop? (this is not a spam)"
- In reply to: Paul Fi: "socket programming"
- Next in thread: Mok: "Re: socket programming"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 15 Feb 2004 00:44:22 -0500
On Sat, 14 Feb 2004 01:19:18 -0800, Paul Fi wrote:
> i have little knowledge of socket programming, but what i know is that
> using sockets we exchange text between endpoints of the socket but
> first we convert the text to array of bytes and we send it to the other
> side of the comm channel and in the other side we get the original
> string by converting from array of bytes to text
>
> my question is instead of having text exchanged is it possible to have
> objects or complex types converted to array of bytes and vice versa with
> sockets?
>
Yes, you can use an array of bytes and this is what Indy
(http://www.indyproject.org). That passes an array of bytes (TBytes) as a
parameter to the Socket.Send and Socket.SendTo methods (see the DotNET
SDK). In fact, recently, I actually was working on some code in DotNET for
the SNTP protocol (Simple Network Time Protocol) which sits on UDP. That
uses a fixed structure including binary bytes and integers.
I must say something about unsigned word and double-word values. Many
protocols where those are sent in binary should be sent in Network byte
order (not the byte order on your machine or in DotNET). For reading a
binary integer from an endpoint, you would use
IPAddress.HostToNetworkOrder. For sending a binary integer to an endpoint,
you would use IPAddress.HostToNetworkOrder. You often have to do this
with simple UDP query/response protocols or with raw sockets.
HTH.
-- J. Peter Mugaas - Indy Pit Crew Internet Direct (Indy) Website - http://www.nevrona.com/Indy Personal Home Page - http://www.wvnet.edu/~oma00215 If I want to do business with you, I will contact you. Otherwise, do not contact me.
- Next message: Jeff Louie: "Re: Interfaces"
- Previous message: William Ryan eMVP: "Re: How to find reliable offshore (India) programming shop? (this is not a spam)"
- In reply to: Paul Fi: "socket programming"
- Next in thread: Mok: "Re: socket programming"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|