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
-1
votes
1 answer

SocketChannel.write(buffer) is blocking and it's write zero byte

When we are write data using socket channel write method. It's taking too much time for small byte of data. For example if many client is connected to my application then it take 43950 ms to write 16249 byte data. It try 442 times to write above…
-1
votes
1 answer

Eclipse gives error message on class variable declarations?

I am practicing networking in java, and I intend to send a file via SocketChannel, with the host and port specified by the user. However when I declare the variables Eclipse gives the error message: "Syntax error on tokes, delete these…
joyalrj22
  • 115
  • 4
  • 12
-1
votes
1 answer

java nio socketChannel.write() missing bytes

System.out.println(" @ bBuffer = " + bBuffer.capacity()); headerBuffer.rewind(); socketChannel.write(headerBuffer); int writen = socketChannel.write(bBuffer); System.out.println(" @ writen = " + writen); bBuffer is an object of type ByteBuffer…
dj lee
  • 1
  • 1
-1
votes
1 answer

java.nio.channels.Selector.select() returns zero

I'm trying to find out, why the selector does not work. Here is the code: //SocketChannel ch //java.nio.channels.Selector impl //Object session SelectionKey sk = ch.register(impl, 0x01, session); int i = impl.select(); System.out.println(i); The…
i.y.
  • 153
  • 11
-1
votes
1 answer

java nio socketchannel: client to multiple servers

my project is actually pretty basic, but I just can't find the right information for it (ie: I can only find how to create a server that accepts multiple clients). The idea is quite simple: I want to create a client to will connect to multiple…
Loose
  • 1
-2
votes
1 answer

Java's SocketChannel.read(ByteBuffer)

Cant seem to find the answer to this in the java docs: Does SocketChannel.read(ByteBuffer) append or overwrite the current ByteBuffer?
Verlix
  • 71
  • 4
-2
votes
1 answer

Problem with Java selector/SocketChannel

I'm having a problem with a multiplayer game. Right now, I'm just trying to get the server to send the current level to the client. The server is definitely sending the data, but it never gets to the client application. Client code: public void…
Jacob_
  • 1
  • 1
-4
votes
2 answers

how to write char array to java socketchannel

how to write char array to java socketchannel. I am not able to write the char data to socketchannel as it takes ByteBuffer.
Prithvi
  • 3
  • 1
1 2 3
16
17