PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Noms de domaine > comp.protocols.tcp-ip > udp socket options
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.protocols.tcp-ip TCP and IP network protocols.

udp socket options

Réponse
 
LinkBack Outils de la discussion
Vieux 25/05/2006, 18h09   #1
bofh1234@hotmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut udp socket options

Hello,

I need to write a UDP application. The first byte in the packet tells
me what type of packet it is. Since I have to use UDP I have to use
recvfrom and sendto. If I do a recvfrom to read the first byte the
rest of the buffer is destroyed. I heard there is an UDP socket option
I can set that will let me read the first byte without destorying the
rest of the buffer. Is this true? If so what is it?

Thanks,
Ben

  Réponse avec citation
Vieux 25/05/2006, 18h15   #2
David Tiktin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: udp socket options

On 25 May 2006, bofh1234@hotmail.com wrote:

> I need to write a UDP application. The first byte in the packet
> tells me what type of packet it is. Since I have to use UDP I
> have to use recvfrom and sendto. If I do a recvfrom to read the
> first byte the rest of the buffer is destroyed. I heard there is
> an UDP socket option I can set that will let me read the first
> byte without destorying the rest of the buffer. Is this true? If
> so what is it?


Perhaps you're thinking of the recvfrom() flag MSG_PEEK? But I've
never used it and don't know how it behaves with UDP.

Dave

--
D.a.v.i.d T.i.k.t.i.n
t.i.k.t.i.n [at] a.d.v.a.n.c.e.d.r.e.l.a.y [dot] c.o.m
  Réponse avec citation
Vieux 25/05/2006, 18h23   #3
bofh1234@hotmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: udp socket options

Yes that it is. My brain turned off for a minute. Thanks.

  Réponse avec citation
Vieux 25/05/2006, 18h33   #4
Rick Jones
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: udp socket options

bofh1234@hotmail.com wrote:
> Yes that it is. My brain turned off for a minute. Thanks.


Since you are going to have to be able to (virtually) strip-off that
first byte anyway when you read the datagram the second time, you
might as well read the entire datagram to begin with.

rick jones

BTW, UDP does not always mean having to use sendto() and recvfrom().
If you "connect()" the UDP endpoint to the one remote IP/port with
which you are communicationg, you can use send() and recv().

All this and more are covered in books like "Unix Network Programming"
by Stevens, Fenner and Rudof. IMO must reading for anyone writing
network applications.

--
The glass is neither half-empty nor half-full. The glass has a leak.
The real question is "Can it be patched?"
these opinions are mine, all mine; HP might not want them anyway...
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
  Réponse avec citation
Vieux 25/05/2006, 23h34   #5
Barry Margolin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: udp socket options

In article <ZTldg.1088$FY7.294@news.cpqcorp.net>,
Rick Jones <rick.jones2@hp.com> wrote:

> bofh1234@hotmail.com wrote:
> > Yes that it is. My brain turned off for a minute. Thanks.

>
> Since you are going to have to be able to (virtually) strip-off that
> first byte anyway when you read the datagram the second time, you
> might as well read the entire datagram to begin with.


It sounds like the type byte can be used to determine how big the rest
of the datagram is, so that he can read it into an appropriately sized
buffer.

Although he could simply set his buffer size to the maximum of any of
the types, and read into that.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h10.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13467 seconds with 13 queries