Starts a server listening for socket connections...
Move to
Next Prev
Up Top
See also
client_start/3
client_stop/1
listener_start/3
listener_stop/3
receive/2
send/2
server_start/4
server_stop/1
IF Computer > MINERVA > Manual > Reference > Predicates > Communication between distributed Minerva processes. > server_start/4

server_start/4

Starts a server listening for socket connections

server_start(+Port, +Backlog, +Callback, -Server)

server_start/4 opens a server socket listening on port Port for incoming connection requests. Backlog sets the maximum queue length for incoming connection requests. If a connection request arrives when the queue is full, the connection is refused.
When a connection request arrives, the server will call the user defined callback predicate Callback, which has to handle the new connection. If the first argument of the the callback predicate is a variable, then this argument will be replaced by the socket argument, that has been created for the new connection.

Arguments

Port               integer
Backlog            integer
Callback           compound or atom
Server             object

Examples

main(_) :-
    server_start(1352, 3, accept_connection(_), _).

accept_connection(Socket) :- open(Socket, read, Input, [socket,buffered,binary]), open(Socket, write, Output, [socket,buffered,binary]), receive(Input, Request), handle_request(Request, Anwer), send(Output, Answer), close(Input), close(Output), close(Socket).

handle_request(Request, Answer) :- ...

See also

server_start/4, server_stop/1, client_start/3, client_stop/1, listener_start/3, listener_stop/1, send/2, receive/2.

read on...
MINERVA
ifcomputer logo
f
Expert Services on the Web
Language
English
Japanese
Server
USA
Japan
Site Access
Local Index
Local Contents
Site Contents
Site Index
Printer Friendly
For imode
For PDA
Search
document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Predicates/sockets/server_start/home_en.html
published 2008/5/12 update 2002/3/19 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 info@ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
scroll to top managed with ubiCMS