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

Java SocketChannel write blocked while reading

I am trying to use SocketChannel.write and SocketChannel.read at the same time in two different threads (Android API Level 25). I configured the SocketChannel as blocking mode. For reading, I created an endless loop to read everything from…
WoooHaaaa
  • 19,732
  • 32
  • 90
  • 138
1
vote
0 answers

Creating an own SocketChannel in Java

I am currently working on a small Networking - Library and trying to unite a few socket related classes like e.g. Socket, SocketChannel, DatagramSocket, DatagramSocketChannel, so that the user is able to implement his own Sockets really simple. The…
Chip
  • 11
  • 3
1
vote
0 answers

JavaMail IdleManager throws "Folder is not using SocketChannels" exception after a while

I'm using IdleManager, in Scala, to listen to a Gmail folder. I already have this props.setProperty("mail.imaps.usesocketchannels", "true") The main part of my code is like this: folder.addMessageCountListener(new MessageCountAdapter() { …
Phu Nguyen
  • 43
  • 5
1
vote
1 answer

Can i send buffer in c# client to java SocketChannel server?

I am creating my game server with java nio, But i can not find how to use socketchannel or send data in c#, how can I solve this problem. Just use i/o?
whtjs
  • 49
  • 6
1
vote
1 answer

Java - Reading from a socketchannel

So I am using SocketChannels in java to send and receive data for a project. The project interacts with a 3rd party who require a ByteBuffer of the data but which is prefixed with 4 bytes which is its length. When receiving I will receive a…
James King
  • 2,425
  • 7
  • 30
  • 45
1
vote
2 answers

Is the SocketChannel returned by ServerSocketChannel.accept() guaranteed to be connected?

This is a pretty basic question, but I can't find a definitive answer for it anywhere: When I accept() a connection from a ServerSocketChannel, am I guaranteed that the returned SocketChannel is "connected", or could it happen that the returned…
Markus A.
  • 12,349
  • 8
  • 52
  • 116
1
vote
1 answer

Non-blocking writes to Java SocketChannel

If I obtain a SocketChannel that is set to the non-blocking mode, what happens when I write to the channel and the underlying socket buffer is full because the other side cannot keep up? Would the data be discarded or something to that effect?
maxim1
  • 53
  • 5
1
vote
0 answers

What's the practical way to keep ChannelId in netty 5.0?

I'm implementing a socket server with netty 5.0 for client connection. I need to keep socket connection with each callee at all time and send message to inform the callee identically. Currently I have a self-defined class called "ChannelMapper"…
Alvin
  • 21
  • 4
1
vote
0 answers

Java NIO SocketChannel read() after write()

I have a client/server application where two users write to each other and also can send large files to each other, i used ServerSocket and Socket classes to do this and everything was fine except of slow file transfer, this was the code: Client…
Peter
  • 409
  • 2
  • 6
  • 14
1
vote
0 answers

nio channel: split messages

I have a Client - Server java nio application. In some cases I need to handle situations like that: on Server: SocketChannel socketChannel = (SocketChannel) key.channel(); for (int i=0;i<30;i++){ …
Max Max
  • 389
  • 1
  • 2
  • 12
1
vote
2 answers

How to get size of data recieved SocketChannel

I'm writing a server for my app, which must get data from client and do smth. The communication is done using SocketChannel, but there is a problem: i only can read previously specified number of bytes from it (as of javadoc for…
TEXHIK
  • 1,369
  • 1
  • 11
  • 34
1
vote
2 answers

Java NIO - SocketChannel.write() on server many times but Client only receive result once

I'm doing an exercise requires making a server - client chat program using Java Non-Blocking IO. At the moment, the way the program works is simple: when a client send a message to the server, the server (which already keep track of all the clients)…
sonlexqt
  • 6,011
  • 5
  • 42
  • 58
1
vote
1 answer

NIO SocketChannel saying there is no data when there is (or selector is not informing me)

I have a functioning client-server apparatus which can successfully connect and send messages to each other using NIO. Right now my only confusion is how I'm supposed to continue reading when socketChannel.read() returns zero. I have a protocol that…
Water
  • 3,245
  • 3
  • 28
  • 58
1
vote
1 answer

Java socket - the socket port

I have written a server in java for my application which needs to uniquely identify each connection. I currently identify each connection by the port of SocketChannel's Socket. Is the port of a socket a number given by JVM? If it is, does this mean…
stju
  • 11
  • 1
1
vote
0 answers

ServerSocketChannel to accept more connections from the same client

my server needs to accept new connections from the same client. Because my client do relogin after 10 hours connected. It is a server/client for iscsi protocol and my client is a microsoft iscsi initiator. So I would like a sugestion. Today I have a…
Felipe Gutierrez
  • 525
  • 1
  • 9
  • 20