Frames streaming via socket [closed] - java

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 3 years ago.
Improve this question
I am making an android app where i should send camera frames via udp/tcp socket
I get each frame as a byte[] array in a FrameCallback
Then i used the socket to send each time MAX_BUFFER_SIZE bytes from the array
as fragments.
But it's not Effcient enough since the array size sent is about 10M, and there will be alot of buffering when the stream will be desplayed.
I can't compress the array too since it's an OMEGA(n) operation, SO
First of all , what protocol is better for this problem? UDP, TCP ?
And in general , how can i send that huge array over socket in a video streaming efficiency level ?

I solved it by using the UDP Protocol
And used Allocation class to compress the data array, it did the work!

Related

HttpClient class AbstractConnPool becames too big,how to solve it ? [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 3 years ago.
Improve this question
The class org.apache.http.pool.AbstractConnPool has this map field:
private final Map<T, RouteSpecificPool<T, C, E>> routeToPool;
If I use a lot of proxy ip, the map size will became bigger and bigger, this will cause oom.
How to solve it?
To be honest, I never had this issue working with an Apache HTP Client. Looking at your memory dump at Httpclient out of memory I see "104655 instances of class org.apache.http.pool.AbstractConnPool$1" which is an anon inner implementation of RouteSpecificPool which is the value type of the field you mentioned.
So the question is, how do you use the client? The connections have to be released at some point and unused and/or expired connections will be cleaned up.
Do never keep connections in the pool forever or do a keep alive for connections you do not use any more! Such things in combination with requests to high diverse targets (aka routes). You have to configure timeouts for usages (see also Apache Httpclient Connection not Released)!

How to exchange objects between client and server without using stub in rmi 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 2 years ago.
Improve this question
I'm trying to send an object from client side to server side in order to modify its attributes and send it back from server to client - but without using a stub.
Any ideas?
Sure:
define your own protocol to enable remote calling
serialize the object on the one side into a stream of bytes, or more 2017ish: into a JSON string
send the bytes / string to the other side
deserialize, update; serialize and sent back.
That is a pretty generic answer; but given your extremely broad input; the best you can hope for (imho).
Further reading: on protocols, on serialization.
You don't need a stub class in the sense of generating one with rmic. Study the preamble to the Javadoc for UnicastRemoteObject for the conditions under which a dynamic stub is generated automatically.

Why is Java so slow in reading from serial port? [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 6 years ago.
Improve this question
So I'm using the SerialPort class to read data from a serial device. my code is as shown below. I researched a little and found out that serial data is read at 100kb/sec. So according to that, my program would have to read the data in just 2 seconds since I have called the readHexString function with 200000 as a parameter and it thus reads 200000 bytes, I just want to know why it takes many minutes to read the data serially?
serialPort.openPort();
serialPort.setParams(SerialPort.BAUDRATE_57600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
int count = 0;
String data = serialPort.readHexString(200000);
You can not assume 100kb/sec
That leads to 34,722 seconds for 2000000 Bytes
I'd like to ask if your device is sending continuously Data? Your Code reads 200.000 Bytes. So you have to wait until the Buffer is full. You could try to cycle smaller amount of data and break if a marker is reached.

Efiiciency for Pagination 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 7 years ago.
Improve this question
I am writing Pagination for a set of records in Java. Here i am talking to a service which fetches a result set of 500 per time. I interact with that service to display at most 50 records at a time with page markers.
Is it a really efficient model or if there is any other way to improve the suggested pagination model ?
Depends on your data.
If your data is rapidly changing, this definitely isn't a suitable method. I would suggest tweaking the service to return only as much requested records that are needed by the page.
If data is static and need not be time dependent, this should work fine. Just fetch the 500 records, put it in a local array and display from there. Once this is exhausted, replenish the same.

How to create socket to receive both text and image [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 8 years ago.
Improve this question
I want to create a server which receives both text and image. For text I used DataInputStream dis.readUTF(), and for image, I used ObjectInputStream ois.readObject() to read the image as byte[]. So how can I write code to detect the data receiving is text or byte[]?
You'll have to use some kind of signal from the client to know whether it is sending text or an image.
Alternatively, you could receive on different ports depending on the type of input.

Categories