TCP packet loss [closed] - java

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 days ago.
Improve this question
When I am trying to send image file through tcp in java it sending but image is corrupted. I am using tcp socket where my server socket is running i am connecting with that and then continue reading file with and sending through outputstream with buffer size 8KB and each packet delay with 16ms.
I try to send different packet size and packet delay but still it corrupted means some pixle is missing in the image file. I want the actual buffer size which can i add and delay for the sending file data through tcp.

Related

UDP data loss program hint in java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm a newbie in networking in java and i know packets may get lost in UDP protocol. I'm looking to make a program which shows the effect of UDP data loss so that the concept becomes clearer. Therefore i want hints for making a program myself which shows data loss using UDP.
You need to write two programs:
A client that sends UDP packets containing a sequence number that it keeps incrementing.
A server program that accepts UDP packets, extracts the sequence number, and checks to see if they any are missing or out of order. If there is no loss or reordering of packets, the server should see the UDP packets in ascending order ... as sent by the client.
Then run the client and server, with the client sending to the server. If packets are missing, that illustrates UDP data loss.

How to send Socket details through a Socket [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am developing a Java application in which I need to pass details of a Socket object to remotely connected computer through a Socket... I tried it by passing the socket object in object output stream. But as "Socket" is not "serializable" it didn't work...
Can anyone help me please? Or tell me whether it is possible or not...
Thank you...
You have the solution at your hand. If you (the server) have 2 opened sockets, one from A and another from B all you have to do is: What is read from A send it to B and what is read from B send it to A. When socket A or socket B is closed (or has an error) you (the server) close both socket and the conversation is over. To deal with this scenario, you need to use select or another non-blocking mechanism to see which socket has data to be read and act accordingly. I would recommended to use a separate thread to do this job, so the server will be free to attend more clients.

Which socket programming is best (TCP/UDP)? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
My client program wants to send a huge file to the server and in return the server program returns a double or triple sized file.
My question is, which approach should I use? Either TCP or UDP.
You could utilize FTP (File Transfer Protocol) for your use case.
It is very common and you can use it with java to get or to upload
files to the FTP server.
Also take a look at this question on SO: File upload in Java through FTP
If you still want to implement it yourself, I would recommend using TCP, since it offers you some services:
Ordered data transfer — the destination host rearranges according to sequence number
Retransmission of lost packets — any cumulative stream not acknowledged is retransmitted
Error-free data transfer
http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Data_transfer
This question is too broad, but the answer is probably TCP; if you're needing to transfer a file, TCP provides ordering and retransmission services that UDP doesn't, and there's no reason to reinvent the wheel.
Along those lines, though, why reinvent HTTP? This sounds like a classic case for using a Web server.
UDP programmin but it will be difficult to implement

Clients connecting automatically to server with sockets java [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
Is there any way,java code, to make clients automatically establish connection to server with sockets in java.
I have some machines on a LAN network, one of them contains a server that listens to all connected clients,i want client to be able to listen server and connect immediately as soon as the server starts.
As I see it, you have two choices:
Write a loop in your client. Something like
boolean connected = false;
while (!connected) {
connected = ... // try to connect
Thread.sleep(/* some time */);
}
Make the clients listen on a port. When the server starts up, it fires a trivial message to that port. When the client gets that message, they know the server is up and they can connect to the server.

Analyze some html pages from StackOverflow [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I need to extract answers from 500 stackoverflow questions at a time, but suddenly I read this error on Eclipse console:
Server returned HTTP response code: 503 for URL:
https://stackoverflow.com/search?q=lucene+IndexWriter+registerMerge%28
and if I use browser after that I read this message:
There are an unusual number of requests coming from this IP address.
To protect our users, we can't process any more requests from this IP address right now.
We'll restore access as quickly as possible, so try again soon.
I do this for a research work. Am I violating some SO rule?
The message is straightforward: you're screenscraping StackOverflow, and SO doesn't want you doing that.
If you still want to spider the site then just rate-limit your accessing, maybe make one request every 100ms or even 250ms instead of 500 at a time (which is what I assume you're doing).

Categories