Questions tagged [socketchannel]

Issues related to socket channel for stream-oriented connecting sockets in Java

A socket channel represents a "selectable channel" for stream-oriented connecting sockets in Java. It is part of the Java NIO library.

249 questions
0
votes
0 answers

Using java.nio.channels.SocketChannel with Selectors for client side

I was trying to use SocketChannel for my Android application. but the issue I am facing is that I am not able to read the response even if I have written to the SocketChannel successfully. Also, I get selKey.isWritable(), selKey.isReadable() and…
Mayank
  • 1,099
  • 4
  • 17
  • 44
0
votes
1 answer

why selector.select() is always return 0

I want to determine port whether open. InetSocketAddress address = new InetSocketAddress("www.google.com", 80); Selector selector = Selector.open(); SocketChannel socketChannel =…
firebroo
  • 85
  • 3
0
votes
1 answer

Java SocketChannel closed on other thread

I have a thread, witch is testing a socketchannel selector. If a socketchannel is connected, and can be read, it should start a message handler thread, where the message is read, and handled. I need to start the handler thread, because there have a…
Zsolt Tolvaly
  • 3,528
  • 4
  • 26
  • 25
0
votes
0 answers

ObjectOutputStream, ObjectInputStream. Cannot cast to ConcurrentHashMap

My client sends a public key to the server. The server puts the public key and the client's ip address in a ConcurrentHashMap and returns the ConcurrentHashMap back to the client. The public key and client's ip is stored in public…
0
votes
1 answer

SocketChannel - read message of several packets

I build a client side (SocketChannel) which is getting big messages (the size of each message is ~1MB-~2MB). How can I get the message ? I'm using selector. When the key isReadable I want to read all the packets of the receiving message. How can I…
user3668129
  • 4,318
  • 6
  • 45
  • 87
0
votes
1 answer

SocketChannel - write does not write all the DATA

I'm trying to send data (400016 bytes) via SocketChannel. for some reason not all the data is being sent. (I expect to see that all the 400016 bytes will be sent) Here's the code: public boolean send(byte[] bytesPayload, int nSize) { …
user3668129
  • 4,318
  • 6
  • 45
  • 87
0
votes
1 answer

Java SocketChannel send multiple files over one socketchannel possible?

I need some suggestion on how to push an end of stream character without having to have sc.shutdownOutput() call being made on the server side after finish sending a file over the socket channel. Here is the bit from server side long curnset…
EdisonCh
  • 13
  • 1
  • 7
0
votes
2 answers

Java Socket.read(ByteBuffer dst) not getting any byte

I am puzzle with my latest predicament with Java Socket programming for three days straight now. I use NIO ByteBuffer and Channel to transfer byte from client to server. I test my code by having client to send 2 files in sequences - the first files…
EdisonCh
  • 13
  • 1
  • 7
0
votes
0 answers

Why couldn't I read a full incoming data by using non-blocking I/O socketchannel

I am trying to testing FTP by using SocketChannel, but it is not really in my expectation. I knew that I need to setup a selector algorithm which select the OP_CONNECT, OP_READ key to perform the connect and read function, everything is working fine…
taymedee
  • 484
  • 2
  • 5
  • 11
0
votes
3 answers

Reading stream over TCP on a SocketChannel with undefined number of Bytes

I am trying to read a stream on a SocketChannel without defining the number of bytes. The alternate solution i thought about is storing different ByteBuffers of a pre-defined size into a list which will allow me afterwards to allocate a new…
Hosni
  • 668
  • 8
  • 29
0
votes
1 answer

Can blocking SocketChannel connect return false?

When I read the documentation for SocketChannel, it seems pretty clear that a blocking SocketChannel connect() call will only ever return true or throw an exception. In other words, it can only return false in non-blocking mode. Is that correct, or…
batkins
  • 11
  • 2
0
votes
1 answer

red5 RTMPClient is not publishing stream if streamname is big enough

I have a Red5 client implementation which publishes streams, loaded from video file to our wowza media server. The problem is that if stream name is to big - approximately more than 90 symbols - the client is not publishing it and fails silently.…
KutaBeach
  • 1,445
  • 21
  • 43
0
votes
1 answer

Java: how to reuse SocketChannel

I need to make 2 requests with one connection to server. I use 'SocketChannel' for this task and I can't do what I need. public static void main(){ ByteBuffer in = null; ByteBuffer out = null; SocketChannel socket = null; try { socket =…
Lunigorn
  • 1,340
  • 3
  • 19
  • 27
0
votes
0 answers

How to send parameter values to server using Socketchannel?

I'm using SocketChannel to send a file from the client to the server in my android application. It's working without any issues. But I need to send a file name as well to the server. Is it possible to set a request parameter to Socketchannel like…
macOsX
  • 447
  • 1
  • 9
  • 19
0
votes
2 answers

The write() method of a SocketChannel do not throw an exception when it should do

I'm writing a server to exchange messages among clients. One issue left to be solved is how to release a channel when a client happens to be closed. What I do is to start a monitor thread in which the all-Clients map is monitored, and I attempt to…
dastan
  • 105
  • 6