LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-15-2003, 09:21 AM   #16
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32

Quote:
Originally posted by ooagentbender
so how do I put together packets?
You are still being pretty vague in your question. Again, a packet is really just a term used for a set of data. Are you trying to put together packets from some well established protocol? If so, you need to read and understand the spec for that protocol.

Are you trying to define your own packets for your own custom protocol? If so, decide what all you need to send in the packet and put it together however you want.

With sockets, you really just send and receive bytes of data. How you translate those bytes is up to you, or up to the protocol spec if using a well-established protocol. As per my previous example, I tend to like to use structs, and send the bytes of the struct by using a pointer to an instance of that struct.

Also, in your previous code that I looked at, you were using the TCP protocol, not UDP. There are some major differences you should understand.
  • TCP is connection-oriented, UDP is not.
  • TCP is stream-based, UDP is not.
  • UDP does not guarantee packets will be delivered, or in order, TCP does so long as the connection remains open long enough.
  • UDP preserves packet boundaries, TCP does not.

This last is an important point. It means that with UDP if you send 100 bytes of data in a single send, the other side will receive 100 bytes of data in a single receive. Or if you send 2 packets of 100 data in 2 sends, it will take 2 receives to retrieve both of those packets. With TCP, you might send 100 bytes of data twice, and with a single receive, the receiver might get all 200 bytes. Or you may try to send 1000 bytes of data with a single send, and the network might be slow enough that the other side needs to use more than one recv to get all 1000 bytes.

It seems that you perhaps need to get a bit better grasp of not only socket programming in general, but maybe also understand C/C++ a little bit before delving too far into it.

Last edited by deiussum; 12-15-2003 at 09:23 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
UDP packets dont seem to go out! linuxspartan Linux - Networking 2 11-06-2004 09:55 PM
udp packets m00t00 Programming 1 11-04-2004 09:20 PM
encapsulating TCP packets in UDP packets... yoshi95 Programming 3 06-03-2004 02:53 PM
How to receive UDP and ICMP packets, by one UDP socket(PMTUD) myself_rajat Linux - Networking 0 05-28-2004 05:43 AM
UDP packets going nowhere jylhar Programming 0 01-05-2004 05:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration