|
-
July 28th, 2004, 01:13 AM
#2
Well '10049' WSAEADDRNOTAVAIL "The requested address is not valid in its context". Seems like the source address is not right. Using struct for header is always better and easier. For using UDP you may have to change the socket to IPPROTO_UDP. As for IP_HDRINCL you should be getting in XP if you have admin previlage. I'm pasting the header of IP and UDP for your easy reference.
Code:
// The IP header structure
//
typedef struct _iphdr
{
unsigned char h_len:4; // Length
unsigned char ver:4; // IP Version
unsigned char tos; // Type of service
unsigned short totlen; // Total length of the packet
unsigned short id; // Unique identifier
unsigned short offset; // Fragment offset field
unsigned char ttl; // Time to live
unsigned char proto; // Protocol(TCP,UDP,ICMP,IGMP...)
unsigned short checksum; // IP checksum
unsigned int srcIP; // Source IP address
unsigned int destIP; // Destination IP address
}IpHeader, * LPIpHeader;
// The UDP header structure
//
typedef struct _udphdr
{
unsigned short sport; // Source Port
unsigned short dport; // Destination Port
unsigned short Length; // Length
unsigned short Checksum; // Checksum
}UdpHeader, * LPUdpHeader;
PS: You also need winsock 2 (link to ws2_32.lib)
Even if our suggestions didn't help, please post the answer once you find it. We took the effort to help you, please return it to others.
* While posting code sections please use CODE tags
* Please check the codeguru FAQ and do a little search to see if your question have been answered before.
* Like a post, Rate The Post
* I blog: Network programming, Bible
I do all things thru CHRIST who strengthens me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|