How to transfer a file by socket PHP to C# -


this question has answer here:

hi after lot of research didn't found solution case

i have c# socket server what's running on server , need transfer files socket website that's in php.

what have ?

php part:

    $file = array('file' => input::file('file'));     $fp = stream_socket_client("tcp://localhost:9192", $error_number, $error_string);     if ( !$fp ) {         echo "$error_number ($error_string)\n";     } else {         fwrite($fp, $file['file']);         }      fclose($fp); 

c# socket server:

        string content = string.empty;          // retrieve state object , handler socket         // asynchronous state object.         stateobject state = (stateobject)ar.asyncstate;         socket handler = state.worksocket;          // read data client socket.          int bytesread = handler.endreceive(ar);          if (bytesread > 0)         {             // there  might more data, store data received far.             state.sb.append(encoding.ascii.getstring(                 state.buffer, 0, bytesread));              // check end-of-file tag. if not there, read              // more data.             content = state.sb.tostring();             if (content.indexof("<eof>") > -1)             {                 // data has been read                  // client. display on console.                 console.writeline("read {0} bytes socket. \n data : {1}",                     content.length, content);                 // echo data client.                 send(handler, content);             }             else             {                 // not data received. more.                 handler.beginreceive(state.buffer, 0, stateobject.buffersize, 0,                 new asynccallback(readcallback), state);             }         } 

when try make connection c# instantly refuses i'm doing wrong ?

i'm using laravel 5 on php part.

i found solution in question:

how receive file on tcp sent using socket.filesend method

sorry waste time :)


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -