Filter löschen
Filter löschen

Non-blocking ServerSocket code in Matlab

6 Ansichten (letzte 30 Tage)
Willy
Willy am 18 Jun. 2013
Beantwortet: Sebastian am 7 Jul. 2015
I am creating multiple ServerSockets ( http://docs.oracle.com/javase/1.5.0/docs/api/java/net/ServerSocket.html) in Matlab. These servers are waiting for a external client to communicate (one client per server). I am currently running multiple ServerSockets and communicating successfully with their external clients. However, the code pauses until each server accepts its corresponding client.
socket1 = ServerSocket1.accept;
% Code Waits until connection
socket2 = ServerSocket2.accept;
% Code Waits until connection
socket3 = ServerSocket3.accept;
% Code Waits until connection
I was wondering if I can open a thread/worker/etc to have all the ServerSockets waiting for their respective client.
So far I tried batch without luck.

Antworten (1)

Sebastian
Sebastian am 7 Jul. 2015
Why are you using multiple ServerSockets anyways? Wouldn't it make more sense to wait for all the clients with one socket, which calls "accept" again after one client has connected? Like that you could handle an arbitrary number of clients.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by