Delphi + Winsock.. Send() function

when using the winsock send() function it returns how much data was sent but how can I check if the data was successfully delivered?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

if you use TCP/IP it guarantees the delivery
UDP does not
You must use some kind of protocol. When you send data, your server must send a reply and when client receives a reply, your send was delivered.
flashdAuthor Commented:
Yes, I am using TCP and thats what I thought. I am acting as the client as the server already exists.
My problem is this sometimes the data received by the server is corrupted.

I've been looking at some delphi examples that send data via TCP and they use.




which is the correct one or does it matter?

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

I have used TCP in many programs written in C++. I always create socket with parameters ( AF_INET, SOCK_STREAM, 0 ).

First parameter is called address family and AF_ and PF_ constants have same values.

So, the difference here is in the last parameter. I don't know does this matter, but IPPROTO_TCP looks OK to me. I've never tried this. Zero works OK for me.

How do you send data to the server? I set the last parameter (flag) of the send to 0.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zero is IP ;-)

 * Constants and structures defined by the internet system,
 * Per RFC 790, September 1981, taken from the BSD file netinet/in.h.

 * Protocols
#define IPPROTO_IP              0               /* dummy for IP */
#define IPPROTO_ICMP            1               /* control message protocol */
#define IPPROTO_GGP             2               /* gateway^2 (deprecated) */
#define IPPROTO_TCP             6               /* tcp */
#define IPPROTO_PUP             12              /* pup */
#define IPPROTO_UDP             17              /* user datagram protocol */
#define IPPROTO_IDP             22              /* xns idp */
#define IPPROTO_ND              77              /* UNOFFICIAL net disk proto */

#define IPPROTO_RAW             255             /* raw IP packet */
#define IPPROTO_MAX             256

if you can not receive reliably, just make simple cut_to_blocks and crc_check_and_confirm_received_block stuff.....
"Sometimes the data received by the server is corrupted" is a giveaway for incorrect Recv code. Remember Recv can return 1 byte legally and you often receive in one call LESS than what was sent. For example the Send() sends 2048 bytes, but a call to Recv only gets 1024 bytes. A subsequent call gets the rest. This is caused by buffering (or the lack of it), transmission errors (big blocks get corrupted so smaller ones are sent), or by proxy servers splitting for better network traffic.
   The normal technique is either
   1) send in the first four bytes the message length. Good for multiple messages across a permanent connection,
   2) keep receiving until the socket is closed (-1 from Recv)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.