Reputation: 302
Im working on a chat project using java swing where i am using Socket programming for chat msg, commands etc. While testing i found that there is data loss in transfers send to server program from client program through socket. After a deep study of code i found that each msg or command send through client program is received with an interval of 650 milliseconds. In between if i try to send more than 1 command like "cmd 1", "cmd 2" and "cmd 3", i receive only "cmd 1" and the second msg gets disappeared or not received and after few milliseconds "cmd 3" receives. Please suggest me a socket program where no data loss should occur to make the program look live.
Upvotes: -1
Views: 119
Reputation: 51445
Please suggest me a socket program where no data loss should occur to make the program look live.
Sure. Your server or client should send a command and wait for a response before sending another command. That's how the Hypertext Transfer Protocol (HTTP) works.
Here are some Java socket programming examples that use a command / response protocol. The last example is a chat client and server.
Upvotes: 0