|
I'm not sure of the actual syntax for the library you are using, but you can send and receive data as a sequence of bytes rather than as a string. Just build your message as a byte array and send from there. Similarly on receive store your data into a byte array. If you are putting long values in the array then you need to know where the value starts in order to extract it.
This link[^] has some sample code that should help you.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Would you know how I change this to send a Byte Aray?
|
|
|
|
|
I don't know anything about AxWinsock (could not find it in MSDN), but the link I sent you explains how to do it with tcp.send. If you are having trouble figuring this out it is always best to go to the documentation and look at the samples provided.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
I try this and it works succesfully:
''Client
Imports System
Imports System.Net.Sockets
Imports System.Text
Public Class Form1
Private Const portNum As Integer = 13
Private Const hostName As String = "hostMachineName" ' or IP "192.168.131.67"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim client As New TcpClient(hostName, portNum)
Dim ns As NetworkStream = client.GetStream()
Dim bytes(1024) As Byte
Dim bytesRead As Integer = ns.Read(bytes, 0, bytes.Length)
Dim xx$
xx = Encoding.ASCII.GetString(bytes, 0, bytesRead)
Beep()
'client.Connect
client.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
'Return 0
End Sub
End Class
'Host
Imports System
Imports System.Net.Sockets
Imports System.Text
Public Class Form1
Private Const portNum As Integer = 13
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim done As Boolean = False
Dim listener As New TcpListener(portNum)
listener.Start()
While Not done
Console.Write("Waiting for connection...")
Dim client As TcpClient = listener.AcceptTcpClient()
Console.WriteLine("Connection accepted.")
Dim ns As NetworkStream = client.GetStream()
Dim byteTime As Byte() = _
Encoding.ASCII.GetBytes(DateTime.Now.ToString())
Try
ns.Write(byteTime, 0, byteTime.Length)
ns.Close()
client.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End While
listener.Stop()
End Sub
End Class
|
|
|
|
|
I am trying to implement a HTTP Proxy.
For my implementation I need to detect the end of response object.
What my current implementation does is, it constantly hears from the remote host ( eg. wwww.google.com ) and forwards to whatever data it receives to the requesting process ( eg. web browser )
What I need to do is try to figure out when a particular http response has ended ?
At this point i need to run a piece of code.
Can somebody tell in the byte array that I receive, how do I detect that a http response has finished ?
|
|
|
|
|
If memory serves, the header of the response will have a content length in it. After that, it's just a matter of counting bytes. There is no special sequence of bytes you can look for that terminates the end of the response.
|
|
|
|
|
|
Excellent! I'm glad someone can confirm my insanity!
|
|
|
|
|
This URL States the various rules for detecting end of HTTP
http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4[^]
But this point is not clear to me
"2.If a Transfer-Encoding header field (section 14.41) is present and has any value other than "identity", then the transfer-length is defined by use of the "chunked" transfer-coding (section 3.6), unless the message is terminated by closing the connection. "
Any idea what this means, and how to use this information to detect end of response.
|
|
|
|
|
I suggest taking a look at an open source proxy like squid and see what it does.
|
|
|
|
|
Dear All,
Can i have a simple example application to generate a licences key for one of my application. Sp that when the client runs the setup in his meachine it need to ask for a key.
Regards,
P.Sri Pavan.
|
|
|
|
|
There are many ways to generate and validate license keys; the good ones are proprietary and there is no code available for them. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You basicly have two chooses:
a) create and develope your own licensing system
b) buy a 3rd party licensing system
|
|
|
|
|
|
Forums are Discussion Boards.
Deepali
|
|
|
|
|
Were you doing some testing on this board? Asking question yourself... answering yourself?
|
|
|
|
|
Possibly trying to boost his reputation?
|
|
|
|
|
its 'Her' actually.
Deepali is a female name. Deepali... are you in India?
|
|
|
|
|
Som Shekhar wrote: Deepali is a female name. Deepali...
Where can I meet her?
|
|
|
|
|
You know? Deepali is angry with us...She doesn't wanna respond to us
|
|
|
|
|
Som Shekhar wrote: You know? Deepali is angry with us...She doesn't wanna respond to us
Too bad, I wanted to meet her.
|
|
|
|
|
JimmyRopes wrote: I wanted to meet her. Hmmm
Deepali, If you are reading this, you got an admirer!!!
|
|
|
|
|
In the forums.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Yes, I was checking as to how it is working in codeproject. Thanks.
Deepali
|
|
|
|
|
No need to say thanks. We were making some fun at best.
It was nice to see some Indian Female on the board
Cheers
Som
|
|
|
|