Reputation: 571
I have a client and server program. The client sends a file to the server by first converting the file to bytes and then send it to the server. The server will then reconstruct the file using the bytes it receives. I am having a problem with the server program. Sometimes, the bytes it receives are incomplete.
Now, I have already searched through the internet and found out that it is a common problem among beginner programmers like myself. I have tried various solutions that I found but nothing worked. (I've been working on this for about 2 days already)
I was wondering what is the proper way of sending and receiving files/bytes between two programs in a LAN? (One being the server and the other is the client, though of course, there can be more than 1 client program that will connect to the server program)
I hope someone can help solve this problem. Please... I hope someone who is well-versed in socket programming and about bytes can provide helpful information on this.
Some extra information: I actually based my code from this forum topic: DANIWEB. Reading through the thread, the program worked perfectly and even managed to send a 400MB+ video file. In my case, I'm only sending small images and document files less than 10mb in size and my server program fails more often that it succeeds.
I already asked a question related to this problem, tried the answer given to me but my program still fails. I also found something in MSDN that is a little similar to the answer given to me in my question. Tried it as well, but my server program still fails.
Upvotes: 1
Views: 1272
Reputation: 1062945
You say "incomplete" - this usually points to one of two things:
It is impossible to interpret more without code; however, as noted in another answer - it may help to offload the socket details to a library. As it happens, I'm working on one currently that I intend to release to OSS pretty soon.
Upvotes: 2
Reputation: 1822
It's difficult to answer, I strongly recommend you a Socket Framework on .net platform. It will save you lots of time to develop by yourself. SuperSocket
Upvotes: 1