I want to make a Server, that lets a Client connect through a socket connection.
The thing I can't get done is that I can not find a method for sending a byte
.
I only found articles and examples over sending Messages and Echoing, but that is not what I need, as the received bytes may not be visible.
To send a single byte
via a connected Socket
, simply get it's OutputStream
and call .write()
on that:
Socket s = ...;
byte b = 100;
s.getOutputStream().write(b);
For more in-depth information and examples, see the Chapter on Sockets from the Java Custom Networking Tutorial .
Socket.getInputStream() and Socket.getOutputStream() is what you are looking for. Also, take a look to this example for further info.
Regards.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.