c# - Leave open socket with ssl stream -


i'm using ssl stream , make https soap request each action need.

can leave channel open, , not send certificate each time, , wait hand shake?

this code i'm using:

static void runclient(string hostname, int port, x509certificate2collection certificates) {     // create tcp/ip client socket.     // machinename host running server application.     tcpclient client = new tcpclient(hostname, port);     console.writeline("client connected.");     // create ssl stream close client's stream.     sslstream sslstream = new sslstream(         client.getstream(),         false,         validateservercertificate);      // server name must match name on server certificate.     try     {         sslstream.authenticateasclient(hostname, certificates, sslprotocols.default, true);         displaysecuritylevel(sslstream);         displaysecurityservices(sslstream);         displaycertificateinformation(sslstream);         displaystreamproperties(sslstream);     }     catch (authenticationexception e)     {         console.writeline("exception: {0}", e.message);         if (e.innerexception != null)         {             console.writeline("inner exception: {0}", e.innerexception.message);         }         console.writeline("authentication failed - closing connection.");         client.close();         return;     }     // encode test message byte array.     // signal end of message using "<eof>".     byte[] messsage = encoding.utf8.getbytes("hello client.<eof>");     // send hello message server.      sslstream.write(messsage);     sslstream.flush();     // read message server.     string servermessage = readmessage(sslstream);     console.foregroundcolor = consolecolor.yellow;     console.writeline("server says: {0}", servermessage);     console.resetcolor();     // close client connection.     client.close();     console.writeline("client closed."); } 


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -