serversocket

SSLServerSocket and certificate setup

被刻印的时光 ゝ 提交于 2019-11-27 15:22:15
I wrote a client/server Java program using ServerSocket and Socket objects. I then modified the code to use SSLServerSocket and 'SSLSocket` however I am getting different Exceptions thrown including: javax.net.ssl.SSLHandshakeException: no cipher suites in common I am hoping to do as much programmatically as I can. I am also okay with self signed certificates. One tutorial I followed suggested creating a certificate with the keytool java application, then moving that file into your java project. I have done that with the terminal command keytool -genkey -alias zastore -keyalg RSA -keystore za

Android ServerSocket programming with jCIFS streaming files

ⅰ亾dé卋堺 提交于 2019-11-27 06:50:50
I've got a bit of an issue and I've been asking regarding it quite a few times, but I think I'm one step closer now, so hopefully someone can help me with the rest. My previous questions: Connect to NAS device from Android How to open files in Android with default viewer using jCIFS Put simply - I want to create an application that: Can connect to a NAS device using jCIFS Is capable of launching files in the default viewer - i.e. a video in the video player The first part is relatively easy and I've already done that, but the second part is what's troubling me and what I've asked about a few

java.net.SocketException: Invalid argument: connect

不羁的心 提交于 2019-11-27 04:01:25
问题 My new laptop (Alienware m17x) throws a java.net.SocketException: Invalid argument: connect when I run the following basic code: Server.java: public static void main (String[] args) throws Exception { ServerSocket serverSocket = new ServerSocket (8888); Socket socket = serverSocket.accept(); } Client.java: public static void main (String[] args) throws Exception { Socket socket = new Socket ("localhost", 8888); } Every time I run Client.java (after starting Server.java) I get this socket

Connect two client sockets

孤街醉人 提交于 2019-11-27 03:23:18
问题 Let's say Java has two kind of sockets: server sockets "ServerSocket" client sockets or just "Socket" Imagine the situation of two processes: X = Client Y = Server The server process Y : has a "ServerSocket", that is listening to a TCP port The client process X : sends a connection request through a "Socket" to Y. Y: Then the accept() method returns a new client type "Socket", when it occurs, the two Sockets get "interconnected", So: the socket in client process, is connected with the socket

Java Server - Multiple ports?

旧城冷巷雨未停 提交于 2019-11-26 21:16:47
问题 I'm about to program a server but am wondering if what I have in mind is possible. My program will be outputting to multiple clients on multiple ports - each port can be accessed by multiple clients. Normally I would use a threaded socket server, but in this case I need it working for multiple ports. The usage I have in mind is in a vague pseudocode below: Start server Listen for incoming connections on several ports Identify the port being connected to If port 1, start a thread listening to

Creating the ServerSocket in a separate thread?

自闭症网瘾萝莉.ら 提交于 2019-11-26 19:20:12
问题 I have a problem with using a ServerSocket in my application. I'm creating the ServerSocket in the constructor of my application. The constructor of the socket calls the accept() method to wait for a client to connect. The problem is that the accept() method is freezing my whole application until a client connects. So I would like to ask if there's an alternative to creating the whole ServerSocket in a separate thread, that the constructor of the ServerSocket and its accept() method is called

SSLServerSocket and certificate setup

谁说胖子不能爱 提交于 2019-11-26 17:11:42
问题 I wrote a client/server Java program using ServerSocket and Socket objects. I then modified the code to use SSLServerSocket and 'SSLSocket` however I am getting different Exceptions thrown including: javax.net.ssl.SSLHandshakeException: no cipher suites in common I am hoping to do as much programmatically as I can. I am also okay with self signed certificates. One tutorial I followed suggested creating a certificate with the keytool java application, then moving that file into your java

How to read all of Inputstream in Server Socket JAVA

为君一笑 提交于 2019-11-26 13:34:59
I am using Java.net at one of my project. and I wrote a App Server that gets inputStream from a client. But some times my (buffered)InputStream can not get all of OutputStream that client sent to my server. How can I write a wait or some thing like that, that my InputStream gets all of the OutputStream of client? (My InputStream is not a String) private Socket clientSocket; private ServerSocket server; private BufferedOutputStream outputS; private BufferedInputStream inputS; private InputStream inBS; private OutputStream outBS; server = new ServerSocket(30501, 100); clientSocket = server

Proper way to close an AutoCloseable

删除回忆录丶 提交于 2019-11-26 12:33:31
What is the most reliable pattern to follow when closing an OutputStream , ServerSocket , or other object that implements the AutoCloseable interface? Should I use try - catch - finally ? Or a shutdown hook. The correct way to use an AutoCloseable instance is with a try -with-resources block, so the resource is reliably closed even if an exception is thrown. Like this: try (OutputStream stream = new ...) { ... // use the resource } catch (IOException e) { ... // exception handling code } You can also control multiple resources using one block (rather than nested blocks): try ( OutputStream

Android ServerSocket programming with jCIFS streaming files

穿精又带淫゛_ 提交于 2019-11-26 12:12:14
问题 I\'ve got a bit of an issue and I\'ve been asking regarding it quite a few times, but I think I\'m one step closer now, so hopefully someone can help me with the rest. My previous questions: Connect to NAS device from Android How to open files in Android with default viewer using jCIFS Put simply - I want to create an application that: Can connect to a NAS device using jCIFS Is capable of launching files in the default viewer - i.e. a video in the video player The first part is relatively