]> granicus.if.org Git - openjpeg/commitdiff
Modification of opj_dec_server to be portable to windows
authorKaori Hagihara <khagihara@users.noreply.github.com>
Tue, 10 May 2011 14:42:00 +0000 (14:42 +0000)
committerKaori Hagihara <khagihara@users.noreply.github.com>
Tue, 10 May 2011 14:42:00 +0000 (14:42 +0000)
applications/jpip/CHANGES
applications/jpip/opj_client/opj_dec_server/Makefile
applications/jpip/opj_client/opj_dec_server/imgsock_manager.c
applications/jpip/opj_client/opj_dec_server/imgsock_manager.h
applications/jpip/opj_client/opj_dec_server/opj_dec_server.c

index 3c10897f352919c93f01011a4fad254010270cd9..8744dcf82a82fe9c4e3525e47d31cffeb53d0dbf 100644 (file)
@@ -5,6 +5,9 @@ What's New for OpenJPIP
 ! : changed
 + : added
 
+May 10, 2011
+! [kaori] Modification of opj_dec_server to be portable to windows  
+
 May 9, 2011
 * [kaori] Removal of c99 from the compile option (to be compatible to win platform) and bool definition in libopenjpip/bool.h
 
index ba99254592e3e46ccb34cc7ba856d4299856d029..0c0772830fd094c48934cd37d5e1028bebfa7042 100644 (file)
@@ -2,7 +2,7 @@ LIBDIR = ../../libopenjpip
 LIBFNAME = $(LIBDIR)/libopenjpip_local.a
 CFLAGS  = -O3 -Wall -I$(LIBDIR)
 LDFLAGS = -L$(LIBDIR) -lm -lopenjpeg -lopenjpip_local
-
+#-lws2_32
 
 ALL = opj_dec_server
 
index e92b874500b905c2493ebc83f776c0850966b500..a7471a11959e710a5e11c25b032110888ab597dd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: imgsock_manager.c 53 2011-05-09 16:55:39Z kaori $
+ * $Id: imgsock_manager.c 54 2011-05-10 13:22:47Z kaori $
  *
  * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
  * Copyright (c) 2002-2011, Professor Benoit Macq
 #define strcasecmp  _stricmp
 #else
 #include <strings.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <netdb.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/uio.h>
-#include <unistd.h>
 #include <sys/param.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#include <netdb.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
 #include "imgsock_manager.h"
 
 #define BUF_LEN 256
 
-int open_listeningsocket()
+SOCKET open_listeningsocket()
 {
-  int listening_socket;
+  SOCKET listening_socket;
   struct sockaddr_in sin;
   int sock_optval = 1;
   int port = 5000;
@@ -69,17 +69,20 @@ int open_listeningsocket()
     exit(1);
   }
 
+  memset(&sin, 0, sizeof(sin));
   sin.sin_family = AF_INET;
   sin.sin_port = htons(port);
   sin.sin_addr.s_addr = htonl(INADDR_ANY);
 
   if ( bind(listening_socket, (struct sockaddr *)&sin, sizeof(sin)) < 0 ){
     perror("bind");
+    closesocket(listening_socket);
     exit(1);
   }
 
   if( listen(listening_socket, SOMAXCONN) == -1){
     perror("listen");
+    closesocket(listening_socket);
     exit(1);
   }
   printf("port %d is listened\n", port);
@@ -87,18 +90,18 @@ int open_listeningsocket()
   return listening_socket;
 }
 
-msgtype_t identify_clientmsg( int connected_socket)
+msgtype_t identify_clientmsg( SOCKET connected_socket)
 {
-  int read_size;
+  int receive_size;
   char buf[BUF_LEN];
   char *magicid[] = { "JPT-stream", "PNM request", "XML request", "CID request", "CID destroy", "JP2 save", "QUIT"};
   int i;
   
-  read_size = read_line( connected_socket, buf);
+  receive_size = receive_line( connected_socket, buf);
 
-  if( read_size == 0){ 
-    fprintf( stderr, "Error to read the header of client message\n");
-    return ERROR;
+  if( receive_size == 0){ 
+    fprintf( stderr, "Error to receive the header of client message\n");
+    return MSGERROR;
   }
 
   for( i=0; i<NUM_OF_MSGTYPES; i++){
@@ -109,10 +112,10 @@ msgtype_t identify_clientmsg( int connected_socket)
   }
   
   fprintf( stderr, "Cannot identify client message type\n");
-  return ERROR;
+  return MSGERROR;
 }
 
-Byte_t * receive_JPTstream( int connected_socket, char *target, char *cid, int *streamlen)
+Byte_t * receive_JPTstream( SOCKET connected_socket, char *target, char *cid, int *streamlen)
 {
   Byte_t *jptstream=NULL, *ptr;
   char buf[BUF_LEN], versionstring[] = "version 1.0";
@@ -121,39 +124,39 @@ Byte_t * receive_JPTstream( int connected_socket, char *target, char *cid, int *
   target[0] = 0;
   cid[0] = 0;
   
-  if((linelen = read_line( connected_socket, buf)) == 0)
+  if((linelen = receive_line( connected_socket, buf)) == 0)
     return NULL;
   if( strncmp( versionstring, buf, strlen(versionstring))!=0){
     fprintf( stderr, "Wrong format\n");
     return NULL;
   }
   
-  if((linelen = read_line( connected_socket, buf)) == 0)
+  if((linelen = receive_line( connected_socket, buf)) == 0)
     return NULL;
 
   if( strstr( buf, "jp2")){ 
     // register cid option
     strcpy( target, buf);
 
-    if((linelen = read_line( connected_socket, buf)) == 0)
+    if((linelen = receive_line( connected_socket, buf)) == 0)
       return NULL;
     strcpy( cid, buf);
     
-    if((linelen = read_line( connected_socket, buf)) == 0)
+    if((linelen = receive_line( connected_socket, buf)) == 0)
       return NULL;
   }
 
   *streamlen = atoi( buf);
-  fprintf( stderr, "Reading Data length: %d\n", *streamlen);
+  fprintf( stderr, "Receiveing Data length: %d\n", *streamlen);
   
       
   jptstream = (unsigned  char *)malloc( (*streamlen));
   ptr = jptstream;
   remlen = (*streamlen);
   while( remlen > 0){
-    redlen = read( connected_socket, ptr, remlen);
+    redlen = recv( connected_socket, ptr, remlen, 0);
     if( redlen == -1){
-      fprintf( stderr, "read jptstream error\n");
+      fprintf( stderr, "receive jptstream error\n");
       break;
     }
     remlen -= redlen;
@@ -164,9 +167,9 @@ Byte_t * receive_JPTstream( int connected_socket, char *target, char *cid, int *
   return jptstream;
 }
 
-void send_stream( int connected_socket, void *stream, int length);
+void send_stream( SOCKET connected_socket, void *stream, int length);
 
-void send_XMLstream( int connected_socket, Byte_t *xmlstream, int length)
+void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, int length)
 {
   Byte_t header[5];
   
@@ -180,7 +183,7 @@ void send_XMLstream( int connected_socket, Byte_t *xmlstream, int length)
   send_stream( connected_socket, xmlstream, length);
 }
 
-void send_CIDstream( int connected_socket, char *cid, int cidlen)
+void send_CIDstream( SOCKET connected_socket, char *cid, int cidlen)
 {
   Byte_t header[4];
 
@@ -193,7 +196,7 @@ void send_CIDstream( int connected_socket, char *cid, int cidlen)
   send_stream( connected_socket, cid, cidlen);
 }
 
-void send_PNMstream( int connected_socket, Byte_t *pnmstream, unsigned int width, unsigned int height, unsigned int numofcomp, Byte_t maxval)
+void send_PNMstream( SOCKET connected_socket, Byte_t *pnmstream, unsigned int width, unsigned int height, unsigned int numofcomp, Byte_t maxval)
 { 
   int pnmlen = 0;
   Byte_t header[7];
@@ -212,13 +215,13 @@ void send_PNMstream( int connected_socket, Byte_t *pnmstream, unsigned int width
   send_stream( connected_socket, pnmstream, pnmlen);
 }
 
-void send_stream( int connected_socket, void *stream, int length)
+void send_stream( SOCKET connected_socket, void *stream, int length)
 {
   void *ptr = stream;
   int remlen = length;
 
   while( remlen > 0){
-    int sentlen = write( connected_socket, ptr, remlen); 
+    int sentlen = send( connected_socket, ptr, remlen, 0);
     if( sentlen == -1){
       fprintf( stderr, "sending stream error\n");
       break;
@@ -228,14 +231,14 @@ void send_stream( int connected_socket, void *stream, int length)
   }
 }
 
-int read_line(int socket, char *p)
+int receive_line(SOCKET connected_socket, char *p)
 {
   int len = 0;
   while (1){
     int ret;
-    ret = read(socket, p, 1);
+    ret = recv( connected_socket, p, 1, 0);
     if ( ret == -1 ){
-      perror("read");
+      perror("receive");
       exit(1);
     } else if ( ret == 0 ){
       break;
@@ -248,12 +251,12 @@ int read_line(int socket, char *p)
   *p = '\0';
 
   if( len == 0)
-    fprintf( stderr, "Header read error\n");
+    fprintf( stderr, "Header receive error\n");
 
   return len;
 }
 
-void response_signal( int connected_socket, bool succeed)
+void response_signal( SOCKET connected_socket, bool succeed)
 {
   Byte_t code;
 
@@ -262,6 +265,6 @@ void response_signal( int connected_socket, bool succeed)
   else
     code = 0;
 
-  if( write( connected_socket, &code, 1) != 1)
+  if( send( connected_socket, &code, 1, 0) != 1)
     fprintf( stderr, "Response signalling error\n");
 }
index a4cb0d1f3c39d84c0507cfeb3a69b21b691561da..6032392ff8f1966d8a73092e90a2af1d5c592707 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: imgsock_manager.h 53 2011-05-09 16:55:39Z kaori $
+ * $Id: imgsock_manager.h 54 2011-05-10 13:22:47Z kaori $
  *
  * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
  * Copyright (c) 2002-2011, Professor Benoit Macq
 #include "bool.h"
 #include "byte_manager.h"
 
+#ifdef _WIN32
+#include <winsock2.h>
+#else
+typedef int SOCKET;
+#define closesocket close
+#endif //_WIN32
+
 /**
  * open listening socket
  *
- * @return file descriptor for the new socket
+ * @return new socket
  */
-int open_listeningsocket();
+SOCKET open_listeningsocket();
 
 #define NUM_OF_MSGTYPES 7
-typedef enum eMSGTYPE{ JPTSTREAM, PNMREQ, XMLREQ, CIDREQ, CIDDST, JP2SAVE, QUIT, ERROR} msgtype_t;
-
+typedef enum eMSGTYPE{ JPTSTREAM, PNMREQ, XMLREQ, CIDREQ, CIDDST, JP2SAVE, QUIT, MSGERROR} msgtype_t;
 
 /**
  * indeitify client message type
@@ -51,7 +57,7 @@ typedef enum eMSGTYPE{ JPTSTREAM, PNMREQ, XMLREQ, CIDREQ, CIDDST, JP2SAVE, QUIT,
  * @param [in] connected_socket file descriptor of the connected socket
  * @return                      message type
  */
-msgtype_t identify_clientmsg( int connected_socket);
+msgtype_t identify_clientmsg( SOCKET connected_socket);
 
 /**
  * receive JPT-stream from client
@@ -62,7 +68,7 @@ msgtype_t identify_clientmsg( int connected_socket);
  * @param [out] streamlen        length of the received codestream
  * @return                          codestream
  */
-Byte_t * receive_JPTstream( int connected_socket, char *target, char *cid, int *streamlen);
+Byte_t * receive_JPTstream( SOCKET connected_socket, char *target, char *cid, int *streamlen);
 
 /**
  * send PGM/PPM image stream to the client
@@ -74,7 +80,7 @@ Byte_t * receive_JPTstream( int connected_socket, char *target, char *cid, int *
  * @param [in]  numofcomp        number of components of the image
  * @param [in]  maxval           maximum value of the image (only 255 supported)
  */
-void send_PNMstream( int connected_socket, Byte_t *pnmstream, unsigned int width, unsigned int height, unsigned int numofcomp, Byte_t maxval);
+void send_PNMstream( SOCKET connected_socket, Byte_t *pnmstream, unsigned int width, unsigned int height, unsigned int numofcomp, Byte_t maxval);
 
 /**
  * send XML data stream to the client
@@ -83,7 +89,7 @@ void send_PNMstream( int connected_socket, Byte_t *pnmstream, unsigned int width
  * @param [in]  xmlstream        xml data stream
  * @param [in]  length           legnth of the xml data stream
  */
-void send_XMLstream( int connected_socket, Byte_t *xmlstream, int length);
+void send_XMLstream( SOCKET connected_socket, Byte_t *xmlstream, int length);
 
 /**
  * send CID data stream to the client
@@ -92,7 +98,7 @@ void send_XMLstream( int connected_socket, Byte_t *xmlstream, int length);
  * @param [in]  cid              cid string
  * @param [in]  cidlen           legnth of the cid string
  */
-void send_CIDstream( int connected_socket, char *cid, int cidlen);
+void send_CIDstream( SOCKET connected_socket, char *cid, int cidlen);
 
 /**
  * send response signal to the client
@@ -100,17 +106,17 @@ void send_CIDstream( int connected_socket, char *cid, int cidlen);
  * @param [in]  connected_socket file descriptor of the connected socket
  * @param [in]  succeed          whether if the requested process succeeded
  */
-void response_signal( int connected_socket, bool succeed);
+void response_signal( SOCKET connected_socket, bool succeed);
 
 /**
- * read a string line (ending with '\n') from client
+ * receive a string line (ending with '\n') from client
  *
  * @param [in]  connected_socket file descriptor of the connected socket
  * @param [out] buf              string to be stored
  * @return                       red size
  */
 
-int read_line(int connected_socket, char *buf);
+int receive_line(SOCKET connected_socket, char *buf);
 #endif /* !IMGSOCK_MANAGER_H_ */
 
 /*! \file
index b00e8ccc5a299714fe1283bb2140a63391acce02..3d95ceeccf1bff7fe8e22ddad09104208f4a1a15 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: opj_dec_server.c 46 2011-02-17 14:50:55Z kaori $
+ * $Id: opj_dec_server.c 54 2011-05-10 13:22:47Z kaori $
  *
  * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
  * Copyright (c) 2002-2011, Professor Benoit Macq
@@ -47,9 +47,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
 #include <unistd.h>
 #include "byte_manager.h"
 #include "msgqueue_manager.h"
 #include "jptstream_manager.h"
 #include "cache_manager.h"
 
+#ifdef _WIN32
+WSADATA initialisation_win32;
+#else
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#endif //_WIN32
+
 //! maximum length of target name
 #define MAX_LENOFTARGET 128
 
@@ -73,7 +78,7 @@
  * @param[in,out] jptlen           address of jptstream length
  * @param[in,out] msgqueue         message queue pointer
  */
-void handle_JPTstreamMSG( int connected_socket, cachelist_param_t *cachelist, Byte_t **jptstream, int *jptlen, msgqueue_param_t *msgqueue);
+void handle_JPTstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist, Byte_t **jptstream, int *jptlen, msgqueue_param_t *msgqueue);
 
 /**
  * handle PNM request message
@@ -83,7 +88,7 @@ void handle_JPTstreamMSG( int connected_socket, cachelist_param_t *cachelist, By
  * @param[in] msgqueue         message queue pointer
  * @param[in] cachelist        cache list pointer
  */
-void handle_PNMreqMSG( int connected_socket, Byte_t *jptstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist);
+void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jptstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist);
 
 /**
  * handle XML request message
@@ -92,7 +97,7 @@ void handle_PNMreqMSG( int connected_socket, Byte_t *jptstream, msgqueue_param_t
  * @param[in] jptstream        address of caching jptstream pointer
  * @param[in] cachelist        cache list pointer
  */
-void handle_XMLreqMSG( int connected_socket, Byte_t *jptstream, cachelist_param_t *cachelist);
+void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jptstream, cachelist_param_t *cachelist);
 
 /**
  * handle ChannelID request message
@@ -100,7 +105,7 @@ void handle_XMLreqMSG( int connected_socket, Byte_t *jptstream, cachelist_param_
  * @param[in] connected_socket socket descriptor
  * @param[in] cachelist        cache list pointer
  */
-void handle_CIDreqMSG( int connected_socket, cachelist_param_t *cachelist);
+void handle_CIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist);
 
 /**
  * handle distroy ChannelID message
@@ -108,7 +113,7 @@ void handle_CIDreqMSG( int connected_socket, cachelist_param_t *cachelist);
  * @param[in]     connected_socket socket descriptor
  * @param[in,out] cachelist        cache list pointer
  */
-void handle_dstCIDreqMSG( int connected_socket, cachelist_param_t *cachelist);
+void handle_dstCIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist);
 
 /**
  * handle saving JP2 file request message
@@ -118,19 +123,28 @@ void handle_dstCIDreqMSG( int connected_socket, cachelist_param_t *cachelist);
  * @param[in] msgqueue         message queue pointer
  * @param[in] jptstream        address of caching jptstream pointer
  */
-void handle_JP2saveMSG( int connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jptstream);
+void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jptstream);
 
 int main(int argc, char *argv[]){
 
-  int connected_socket;
+  SOCKET connected_socket;
   struct sockaddr_in peer_sin;
   Byte_t *jptstream = NULL;
   int jptlen = 0;
   msgqueue_param_t *msgqueue = gene_msgqueue( true, NULL);
   bool quit = false;
+
+#ifdef _WIN32
+  int erreur = WSAStartup(MAKEWORD(2,2),&initialisation_win32);
+  if( erreur!=0)
+    fprintf( stderr, "Erreur initialisation Winsock error : %d %d\n",erreur,WSAGetLastError());
+  else
+    printf( "Initialisation Winsock\n");
+#endif //_WIN32
   
   int listening_socket = open_listeningsocket();
-  socklen_t addrlen = sizeof(peer_sin);
+  
+  int addrlen = sizeof(peer_sin);
 
   cachelist_param_t *cachelist = gene_cachelist();
   
@@ -165,19 +179,19 @@ int main(int argc, char *argv[]){
     case QUIT:
       quit = true;
       break;
-    case ERROR:
+    case MSGERROR:
       break;
     }
         
     printf("cut the connection. listening to port\n");
-    if( close(connected_socket) == -1 ){
+    if( closesocket(connected_socket) != 0){
       perror("close");
       return -1;
     }
     if( quit)
       break;
   }
-  if( close(listening_socket) == -1 ){
+  if( closesocket(listening_socket) != 0){
     perror("close");
     return -1;
   }
@@ -190,10 +204,18 @@ int main(int argc, char *argv[]){
   save_codestream( jptstream, jptlen, "jpt");
   free( jptstream);
 
+#ifdef _WIN32
+  if( WSACleanup() != 0){
+    printf("\nError in WSACleanup : %d %d",erreur,WSAGetLastError());
+  }else{
+    printf("\nWSACleanup OK\n");
+  }
+#endif
+
   return 0;
 }
 
-void handle_JPTstreamMSG( int connected_socket, cachelist_param_t *cachelist,
+void handle_JPTstreamMSG( SOCKET connected_socket, cachelist_param_t *cachelist,
                          Byte_t **jptstream, int *jptlen, msgqueue_param_t *msgqueue)
 {
   Byte_t *newjptstream;
@@ -231,7 +253,7 @@ void handle_JPTstreamMSG( int connected_socket, cachelist_param_t *cachelist,
   response_signal( connected_socket, true);
 }
 
-void handle_PNMreqMSG( int connected_socket, Byte_t *jptstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist)
+void handle_PNMreqMSG( SOCKET connected_socket, Byte_t *jptstream, msgqueue_param_t *msgqueue, cachelist_param_t *cachelist)
 {
   Byte_t *pnmstream;
   ihdrbox_param_t *ihdrbox;
@@ -239,14 +261,14 @@ void handle_PNMreqMSG( int connected_socket, Byte_t *jptstream, msgqueue_param_t
   cache_param_t *cache;
   int fw, fh;
   
-  read_line( connected_socket, cid);
+  receive_line( connected_socket, cid);
   if(!(cache = search_cacheBycid( cid, cachelist)))
     return;
 
-  read_line( connected_socket, tmp);
+  receive_line( connected_socket, tmp);
   fw = atoi( tmp);
   
-  read_line( connected_socket, tmp);
+  receive_line( connected_socket, tmp);
   fh = atoi( tmp);
 
   pnmstream = jpt_to_pnm( jptstream, msgqueue, cache->csn, fw, fh, &cache->ihdrbox);
@@ -256,12 +278,12 @@ void handle_PNMreqMSG( int connected_socket, Byte_t *jptstream, msgqueue_param_t
   free( pnmstream);
 }
 
-void handle_XMLreqMSG( int connected_socket, Byte_t *jptstream, cachelist_param_t *cachelist)
+void handle_XMLreqMSG( SOCKET connected_socket, Byte_t *jptstream, cachelist_param_t *cachelist)
 {
   char cid[MAX_LENOFCID];
   cache_param_t *cache;
 
-  read_line( connected_socket, cid);
+  receive_line( connected_socket, cid);
   if(!(cache = search_cacheBycid( cid, cachelist)))
     return;
   
@@ -272,13 +294,13 @@ void handle_XMLreqMSG( int connected_socket, Byte_t *jptstream, cachelist_param_
   free( xmlstream);
 }
 
-void handle_CIDreqMSG( int connected_socket, cachelist_param_t *cachelist)
+void handle_CIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist)
 {
   char target[MAX_LENOFTARGET], *cid = NULL;
   cache_param_t *cache;
   int cidlen = 0;
 
-  read_line( connected_socket, target);
+  receive_line( connected_socket, target);
   cache = search_cache( target, cachelist);
   
   if( cache){
@@ -290,23 +312,23 @@ void handle_CIDreqMSG( int connected_socket, cachelist_param_t *cachelist)
   send_CIDstream( connected_socket, cid, cidlen);
 }
 
-void handle_dstCIDreqMSG( int connected_socket, cachelist_param_t *cachelist)
+void handle_dstCIDreqMSG( SOCKET connected_socket, cachelist_param_t *cachelist)
 {
   char cid[MAX_LENOFCID];
 
-  read_line( connected_socket, cid);
+  receive_line( connected_socket, cid);
   remove_cachecid( cid, cachelist);
   response_signal( connected_socket, true);
 }
 
-void handle_JP2saveMSG( int connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jptstream)
+void handle_JP2saveMSG( SOCKET connected_socket, cachelist_param_t *cachelist, msgqueue_param_t *msgqueue, Byte_t *jptstream)
 {
   char cid[MAX_LENOFCID];
   cache_param_t *cache;
   Byte_t *jp2stream;
   Byte8_t jp2len;
 
-  read_line( connected_socket, cid);
+  receive_line( connected_socket, cid);
   if(!(cache = search_cacheBycid( cid, cachelist)))
     return;