C source code udp file transfer
Branches Tags. Could not load branches. Could not load tags. Latest commit. Git stats 8 commits. Failed to load latest commit information.
View code. Make sure that a server process is running on a computer with the given IP address and on the given port before starting the client. Skip to content. This repository has been archived by the owner. It is now read-only. Star 2. Branches Tags. Below is a features comparison chart to better help you understand the side by side differences each system supports.
When deciding what UDP tool to use, you have several factors to keep in mind. Many of issues arise when dealing with packet loss and recovery. For instance, UDT has been known to fail completely if even the slightest packet loss is reported, whereas Google QUIC has made significant advancements in addressing this issue. Something like this:. The client must do a recvfrom from the server after it sends the buffer to the server!
Something like this. Note that you can use a numeric value -1 or 0 to indicate if the file exists or not. And if the file exists, you can probably pass the file length in the initial message -- this way, the client would know how much data it needs to read. Btw, in the above code, we need to add 1 to account for the NUL character. Also, once this step is done, the client code should call recvfrom in a loop to receive data from the server, as communicated in the earlier step.
Note that if the file is too big, then you probably want to read it only as much as the message you want to send -- with UDP you can send upto 64K but you should ideally send only upto 1 MUT around bytes. After receiving a filename from client, check whether it exists.
See What's the best way to check if a file exists in C? Then open the file and send it buffer by buffer e. Simutaneously, the client receive it and write to a new file named filename. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 8 years, 4 months ago. Active 6 years, 6 months ago.
0コメント