2 * $Id: opj_dec_server.c 54 2011-05-10 13:22:47Z kaori $
4 * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
5 * Copyright (c) 2002-2011, Professor Benoit Macq
6 * Copyright (c) 2010-2011, Kaori Hagihara
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
32 * \brief opj_dec_server is a server to decode JPT-stream and communicate locally with JPIP client, which is coded in java.
34 * \section impinst Implementing instructions
35 * Launch opj_dec_server from a terminal in the same machine as JPIP client image viewers. \n
36 * % ./opj_dec_server [portnumber]\n
37 * ( portnumber=50000 by default)\n
38 * Keep it alive as long as image viewers are open.\n
40 * To quite the opj_dec_server, send a message "quit" through the telnet.\n
41 * % telnet localhost 50000\n
43 * Be sure all image viewers are closed.\n
44 * Cache file in JPT format is stored in the working directly before it quites.
53 WSADATA initialisation_win32;
56 int main(int argc, char *argv[]){
58 dec_server_record_t *server_record;
63 port = atoi( argv[1]);
66 int erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
68 fprintf( stderr, "Erreur initialisation Winsock error : %d %d\n",erreur,WSAGetLastError());
70 printf( "Initialisation Winsock\n");
73 server_record = init_dec_server( port);
75 while(( client = accept_connection( server_record)) != -1 )
76 if(!handle_clientreq( client, server_record))
79 terminate_dec_server( &server_record);
82 if( WSACleanup() != 0){
83 printf("\nError in WSACleanup : %d %d",erreur,WSAGetLastError());
85 printf("\nWSACleanup OK\n");