Hi,
I need a bit of explanation (or pointers to online references) on socket
programming in linux. How do I send a data structure over the internet
and how mtu affects the data flow? does the computer wait til the local
buffer reaches a treshold before it sends? if so, how do i extract each
structure with its corresponding header and body? I can find only htons
and htonl for byte ordering conversion. What do I do with a struct
that's, say, 42 or 75 bytes?
I'm new to socket programming. I hope u guys can help. Many many thanks
in advance :-) 2 5210
PH wrote: Hi, I need a bit of explanation (or pointers to online references) on socket programming in linux.
You're better off asking this in linux-specific newsgroups, or some
newsgroup related to networking. This newsgroup is about standard C, and
the C standard doesn't say anything about sockets (it's a platform-
specific library extention, originating with BSD Unix I think).
Best regards,
Sidney
On Sun, 16 Nov 2003 09:20:50 +0800, PH <ph******@hotpop.com> wrote: Hi, I need a bit of explanation (or pointers to online references) on socket programming in linux. How do I send a data structure over the internet and how mtu affects the data flow? does the computer wait til the local buffer reaches a treshold before it sends?
As already said, the socket part is not Standard C and offtopic;
although I would add for generic sockets, as opposed to any Linux
specifics, I believe comp.unix.programmer is also good.
if so, how do i extract each structure with its corresponding header and body? I can find only htons and htonl for byte ordering conversion. What do I do with a struct that's, say, 42 or 75 bytes?
However, all BSD-type sockets I know of transport memory contents
unchanged, so you have the issue of whether the representation of data
in memory on system is the same as that on another -- and, if in C,
*that* is ontopic; the same issue arises for fwrite'ing and fread'ing
binary files which is standard; and the answer is it's not required --
many details of the representation depend on the 'implementation', a
term of art that basically means the combination of CPU, compiler,
library, and system/OS you use, with some rare exceptions that don't
matter here; and in fact *do* vary between implementations.
If both/all ends are the same architecture e.g. Linux/GNU/x86 *and
using the same compiler/options*, you can probably get away with just
sending/recving an identically declared struct and it will work; for
any other case you probably need to worry about either defining and
converting to and from a common representation, or defining pairwise
conversions between all (current? expected? possible?) platforms; and
even for a homogenous environment it is better to do this, because
they may well become heterogenous in the future.
An obvious common (platform-independent) form is text; because of its
simplicity and ease of debugging this is used in many Internet
application formats (SMTP/mail, NNTP/news, HTTP/HTML) though by no
means all (cf SNMP). Although typically somewhat less efficient, text
is simpler to define and often to implement correctly, and in modern
applications the inefficiency is rarely a problem. This is supported
in C by s[n]printf and sscanf, and more specific routines like strtol
and even wcstombs. Remember that C requires strings to be terminated
by a null character, but it is usual to not actually send that null,
and the recv'er usually needs to (allow for and) add it.
Another possibility is a binary format like XDR (provided on many?
most? Unices as part of the "Sun" RPC = Remote Procedure Call package)
or (more complicated) ASN.1; and you can always define your own,
possibly using {n,h}to{h,n}{s,l} for network-endian integers in the
same way as the lower IP levels.
I'm new to socket programming. I hope u guys can help. Many many thanks in advance :-)
- David.Thompson1 at worldnet.att.net This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: pyguy2 |
last post by:
Issues of socket programming can be wierd, so I'm looking for some
comments.
In my python books I find exclusive use of socket.close(). From my
other readings, I know about a "partial close...
|
by: John Sheppard |
last post by:
Hi all,
I am not sure that I am posting this in the right group but here it goes anyway. I am new to socket programming and I have been searching on the internet to the questions I am about to pose...
|
by: John Sheppard |
last post by:
Thanks to everyone that responded to my previous Socket Programming question. Now I have run into some behavior that I don't quite understand.
Programming environment. VS.NET 2003, C#, Windows...
|
by: mscirri |
last post by:
The code below is what I am using to asynchronously get data from a
PocketPC device. The data comes in fine in blocks of 1024 bytes but
even when I send no data from the PocketPC constant blocks of...
|
by: djc |
last post by:
I read a network programming book (based on framework 1.1) which indicated
that you should 'never' use the RecieveTimeout or the SendTimeout 'socket
options' on TCP sockets or you may loose data. I...
|
by: Uma - Chellasoft |
last post by:
Hai,
I am new to VB.Net programming, directly doing socket programming. In C, I
will be able to map the message arrived in a socket directly to a structure.
Is this possible in VB.Net. Can...
|
by: atlaste |
last post by:
Hi,
In an attempt to create a full-blown webcrawler I've found myself
writing a wrapper around the Socket class in an attempt to make it
completely async, supporting timeouts and some scheduling...
|
by: shonen |
last post by:
I'm currently attempting to connect to a shoutcast server
pull down the information from here and then I'll parse it.
I got this working with the httplib, which was great, the problem is I want...
|
by: =?Utf-8?B?Sm9obg==?= |
last post by:
Hi all,
I am new to .net technologies.
ASP.NET supports socket programming like send/receive in c or c++?
I am developing web-site application in asp.net and code behind is Visual
C#. In...
|
by: Stuart |
last post by:
I am in the process of teaching myself socket programming. I am
"playing around" with
some simple echo server-client programs for m the book TCP/IP Sockets
in C.
The Server program is:
...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
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...
| |