Re: how to write a raw socket server using UDP

2007-11-28 Thread H.fazaeli


the 2 most common cause for sendto() failure on raw sockets are:

- badly initialized IP header. note that ip_len and ip_off must be in
 host byte order. all other fields must be in net byte order.
- badly initialized destination address.

writing a raw socket server is not much different than other socket
servers:

s = socket(AF_INET, SOCK_RAW, 0);
if (bind(s, ...) != 0)
   errx(...)
while (1)
recvfrom(s, ...)
/* recv buffer contains a packet starting with IP header */



sourav das wrote:

hello all,

 i m a new comer. i wrote a raw socket client 
using setsockopt (sock, IPPROTO_IP. IPHDRINCL, )using UDP. ihave followed 
MS_Press network programming . it is showing 19 bytes sent successfully. when 
trying to send more than 19 bytes using sendto(sock, ...) function , it is 
showing socket error on sending. i want to know how to write a raw socket server 
program so that to catch and display the data sent by the  client.


 


thanks a lot,

keep fit,

 


regards,

spike.




  

Be a better sports nut!  Let your teams follow you 
with Yahoo Mobile. Try it now.  http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ

___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]



  


___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


how to write a raw socket server using UDP

2007-11-27 Thread sourav das
hello all,

 i m a new comer. i wrote a raw socket client 
using setsockopt (sock, IPPROTO_IP. IPHDRINCL, )using UDP. ihave followed 
MS_Press network programming . it is showing 19 bytes sent successfully. when 
trying to send more than 19 bytes using sendto(sock, ...) function , it is 
showing socket error on sending. i want to know how to write a raw socket 
server 
program so that to catch and display the data sent by the  client.

 

thanks a lot,

keep fit,

 

regards,

spike.




  

Be a better sports nut!  Let your teams follow you 
with Yahoo Mobile. Try it now.  
http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: how to write a raw socket server using UDP

2007-11-27 Thread Ivan Voras
sourav das wrote:
 hello all,
 
  i m a new comer. i wrote a raw socket client 
 using setsockopt (sock, IPPROTO_IP. IPHDRINCL, )using UDP. ihave followed 
 MS_Press network programming . it is showing 19 bytes sent successfully. when 
 trying to send more than 19 bytes using sendto(sock, ...) function , it 
 is 
 showing socket error on sending. i want to know how to write a raw socket 
 server 
 program so that to catch and display the data sent by the  client.

I don't think you can do it with the socket API, try using bpf or netgraph.



signature.asc
Description: OpenPGP digital signature


Re: how to write a raw socket server using UDP

2007-11-27 Thread Thierry Herbelot
Le Tuesday 27 November 2007, sourav das a écrit :
 hello all,

  i m a new comer. i wrote a raw socket client
 using setsockopt (sock, IPPROTO_IP. IPHDRINCL, )using UDP. ihave
 followed MS_Press network programming . it is showing 19 bytes sent

is this the best reference you found ? a better text is Unix network 
programming by Stevens.

the canonical program using raw socket is ping, and you can find its source in 
the FreeBSD src tree

Happy reading

TfH
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: how to write a raw socket server using UDP

2007-11-27 Thread Edwin Groothuis
On Tue, Nov 27, 2007 at 01:31:22AM -0800, sourav das wrote:
  i m a new comer. i wrote a raw socket client 
 using setsockopt (sock, IPPROTO_IP. IPHDRINCL, )using UDP. ihave followed 
 MS_Press network programming . it is showing 19 bytes sent successfully. when 
 trying to send more than 19 bytes using sendto(sock, ...) function , it 
 is 
I use net/libdnet for all my IP/UDP/TCP/etc packet creation
requirements.

Edwin
-- 
Edwin Groothuis  |Personal website: http://www.mavetju.org
[EMAIL PROTECTED]|  Weblog: http://www.mavetju.org/weblog/
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]