To send HTTP requests, you can use HttpWebRequest, such as:
HttpWebRequest Logonreq = (HttpWebRequest) webrequest.create ("http://127.0.0.1:8097");
You can also send base bytes directly, but pay attention to:
(1) There should be waiting between sending and receiving, otherwise the data will not be received.
(2) Pay attention to the use of \ r \ n, do not have extra space.
stringLogonreqstr =""; Logonreqstr+="POST * http/1.1\r\n"; Logonreqstr+="content-type:text/xml;charset=iso-8859-1\r\n"; Logonreqstr+="connection:keep-alive\r\n"; Logonreqstr+="soapaction:http://www.lucian.com/2001/04/ap#logonrequest\r\n"; Logonreqstr+="content-length:263\r\n"; Logonreqstr+="\ r \ n"; Logonreqstr+="<soap-env:envelope xmlns:soap-env=\ "http://schemas.xmlsoap.org/soap/envelope/\" ><SOAP-ENV:Body> <ap-msg:logonrequest xmlns:ap-msg=\ "http://www.lucin.com/2001/04/ap\" ap-msg:username=\ "\" AP-MSG:Password=\ "\ "Clientrequesthandle=\" 3208\ "/></soap-env:body></soap-env:envelope>"; byte[] Send =Encoding.UTF8.GetBytes (LOGONREQSTR); Channel.send (Send,0, send. Length); Thread.Sleep ( ); byte[] recvbuff=New byte[1024x768]; intRecvlen = Channel.receivebysize (Recvbuff,0, Channel.availabledatanum, the); stringrecv = Encoding.ASCII.GetString (Recvbuff,0, Recvlen);string[] Sarray = Regex.Split (recv,"\ r \ n", regexoptions.ignorecase);
C # sends HTTP requests