472,992 Members | 3,244 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 software developers and data experts.

Network programming


Hi,
I'm doing network program which
send TCP packet.
I have problem to send such a packet.

I create socket:
s = WSASocket(AF_INET, SOCK_RAW, IPPROTO_RAW , NULL, 0,0);
then:
ret = setsockopt(s, IPPROTO_IP, IP_HDRINCL, (char *)&bOpt, sizeof(bOpt));

I built IP and TCP header : ipHdr and tcpHdr with specific settings.

Next:
memcpy(ptr, &ipHdr, sizeof(ipHdr)); ptr += sizeof(ipHdr);
memcpy(ptr, &tcpHdr, sizeof(tcpHdr)); ptr += sizeof(tcpHdr);
memcpy(ptr, strMessage, strlen(strMessage)); // strMessage="any text"

memset( &remote, 0, sizeof remote );
remote.sin_family = AF_INET;
remote.sin_port = htons(iToPort);
remote.sin_addr.s_addr = inet_addr("10.36.36.55");;

....
ret = connect(s, (struct sockaddr*)&remote, sizeof remote);
....
iTotalSize = sizeof(ipHdr) + sizeof(tcpHdr) + strlen(strMessage);
ret = sendto(s, ptr, iTotalSize, 0, (struct sockaddr*)&remote,sizeof
remote);

( if I made cout << ptr, I can see only first letter of 'strMessage' )

End nothing is sent. ( ret = 58 B )
What is wrong ?

Perhaps anybody has code sending preparing TCP packets.

Regards,
grzybek







Jul 19 '05 #1
2 2413
"grzybek" <gr*****@freebsd.gze.pl> wrote in message
news:bm**********@news2.ipartners.pl...

Hi,
I'm doing network program which
send TCP packet.
I have problem to send such a packet.

[...]

Unfortunately (or fortunately), the C++ standard doesn't address such topics
as sockets. Please take these types of questions to a newsgroup pertaining
to your target platform.
Jul 19 '05 #2
Hi,

More than you ever want to know about socket's programming:

http://www.developerweb.net/sock-faq/flatfaq.php

Regards, Ron AF Greve.
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Alex Ang | last post by:
I have written the following VBScript program. It is stored into a file "map_drive.vbs". It successfully mapped to a network drive \\server1\data. Dim WshNetwork Set WshNetwork =...
1
by: mch2k2 | last post by:
Hello All I have just started working on Pyhton. I need urgent help regarding Python Network Programming. I want the elctronic version of the Book: Foundations of Python Network programming by...
3
by: Jay | last post by:
Hi, I implemeneted an FTP client and server long time back using Java. I found sockets porgramming in java quite useful and easy to handle. I now wanted to implement a similar program using C++....
6
by: John Walton | last post by:
Hello, everyone. I just began school, and they already assigned us science fair. Since I'm in 8th grade, I get to do demonstrations for our projects. I'm probably going to demonstrate Python's...
2
by: Jesse Engle | last post by:
i'm learning how to do some basic low-level network programming. the site i'm reading talks about "network byte order" and "host byte order". the thing is, it doesn't give an explanation as to what...
4
by: Wayne M J | last post by:
I have "Professional .Net Network Programming" and "Network Programming for MS Windows 2nd Ed", but I find both of these to be lacking in what I am looking for. Has there been any books printed...
5
by: Terry | last post by:
Could someone please suggest me a good book to learn network programming. I have been programming in C#/VB.NET/VB 6.0 and have also used a bit of C++ (not MFC/ATL/COM) I am a total novice when...
6
by: Eric | last post by:
Does anyone know of any GOOD network programming book(s) that are C# based, as well as any online tutorials and forums on network programming? Thanks
2
by: ppuniversal | last post by:
Hello, Can someone tell a good Tutorial on Network Programming in C++, except Beej's Guide and Vijay Mukhi's tutorials. I want to make a Client Server application in C++ which will involve...
9
by: Mex | last post by:
Hi, I'm looking for a good book for beginners about Network Programming. Besides Stevens' book, I would like something specific for C++ language. Any suggestions? Thanks in advantage, Massimo
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.