![]() |
| | #1 |
| Registered User Join Date: Oct 2008
Posts: 66
| Socket Programming in C Code:
struct MyHdr{
unsigned char seq; //sequence number
unsigned char wndwsize; //size of the send window
unsigned char pcktsize; //packet size
data char[sizeof pcktsize]; //data array size of packetsize (-overhead)
};
Here's what I have been playing with Code:
while(fread(buffer,1,64,in) !=0){
struct MyHdr packet;
resent =0;
count++;
packet.pcktsize = buffer;//copy buffer into our packet 64bytes
packet.seq = count;
packet.wndwsize = count;
do
{
//something with a CRC
//
}
send(sockfd,packet);
}
|
| TaiL is offline |
| | #2 |
| Registered User Join Date: Oct 2008
Posts: 66
| can someone move this to the C programming forum? |
| TaiL is offline |
| | #3 | |
| subminimalist Join Date: Jul 2008 Location: NYC
Posts: 3,944
| Quote:
Before you can do something special in the way that you want it, you may have to be able to do something normal and basic. So trying going through a simple socket/networking tutorial and write a simple client and server program or something. They use send and recv. Then you will have the understanding you need to proceed onto constructing, transmitting, and deconstructing packets. Right now, you do not have this basic understanding, so there is not much that can be said, I think.
__________________ Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS | |
| MK27 is offline |
| | #4 |
| Registered User Join Date: Sep 2004 Location: California
Posts: 2,845
| You do not need to worry about the header portion of the packet; this will be done for you. All you need to worry about is the packet payload (the data you are sending and receiving). In other words, something like this is perfectly valid: Code: send(fd, "here is some data", 18, 0); |
| bithub is offline |
| | #5 |
| Registered User Join Date: Aug 2009
Posts: 2
| writing dhcp client using sockets Hi all, Can anybody give me a guideline for writing a DHCP client using socket programming on Linux platform? Any kind of help, suggestion of good books and links will be highly appreciated ... Thanks and regards, Dash |
| dash is offline |
| | #6 |
| Registered User Join Date: Aug 2009
Posts: 1
| netlink sockets.. what are netlink sockets. When and why they are used. |
| Maniraj Patri is offline |
| | #7 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
| "me too" bumpers should start a new thread.
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| socket programming question, closing sockets... | ursula | Networking/Device Communication | 2 | 05-31-2009 05:17 PM |
| Socket Help - Multiple Clients | project95talon | C Programming | 5 | 11-17-2005 02:51 AM |
| socket programming in linux | crazeinc | C Programming | 1 | 05-27-2005 07:40 PM |
| when to close a socket | Wisefool | Networking/Device Communication | 5 | 11-02-2003 10:33 AM |
| socket newbie, losing a few chars from server to client | registering | Linux Programming | 2 | 06-07-2003 11:48 AM |