Dear Experts,
good morning, I am working on a project. In which i am unable to send data on a particular ip in 8 bits unsigned integer kindly guide me.

I have to send st first 2 bits unsigned integer then 8 bits unsigned integer.

e.g.
i have to send followning data
00000010 (2 bits unsigned integer)
00001011 (8 bits unsigned integer)


Regards,

pardeep

winsock1.close
winsock1.connect (ip, port)
winsock1.senddata ("what ever data you want")

but if you want to send pure bytes you need to convert them to ascii values then store them in a string and then send them

commented: Nice suggestion. +4

Thanks for your acknowledgement
I think i am doing as per your guideline for clearance i am giving my code as follows:

Dim strRequestConnection As String
strRequestConnection = Chr(2) & Chr(11)'is it correct for sending 0000001000001011

If Winsock1.State = sckConnected Then
Winsock1.SendData strRequestConnection
End If

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData (strData)' WHAT IS STRDATA AND BYTESTOTAL
End Sub

I AM GETTING DATA IN BYTESTOTAL EITHER 2 OR 5 BUT NO DATA IN STRDATA.

why do you have getdata are you expecting data back?

no after getting this message (on winsock's remote IP) i will get another message in bytes on my system.

For more clearance i am sending documentation.
Arrangement is that MyPc(192.168.1.100) is going to send a request connection Message in BigEndian format to RemotePC(192.168.1.199) after getting this message RemotePC(192.168.1.199)will send me a "Operation Session" message but by code is unable to read it. for message detail i am giving you detail and coding.

Format 2 byte unsigned integer
Request Connection Message 0 0 0 0 0 0 1 0 0 byte
0 0 0 0 1 0 1 1 1 byte

Operation Session Message 0 0 0 0 0 0 0 1 0 byte
0 0 0 0 0 0 0 1 1 byte

Codes
Dim strData As String, MsgID As Integer, MsgSource As Integer, VentID1 As Long, VentID2 As Long, VentID As Long, AlarmCode As Integer
Dim WinsockIP As Integer
Dim strVent As String, Tsecfrom As String
Dim TSec As Date
Private Sub cmdConnect_Click()

Winsock1.RemoteHost = "192.168.1.199"
Winsock1.RemotePort = 4600
Winsock1.Connect
end sub

Private Sub cmdSend_Click()
Dim strRequestConnection As String
strRequestConnection = Chr(2) & Chr(11)'for sending request connection message
TSec = Now()
If Winsock1.State = sckConnected Then
Winsock1.SendData strRequestConnection
End If
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Debug.Print "192.168.1.199"
Debug.Print bytesTotal
Winsock1.GetData (strData)
MsgID = Asc(Mid(strData, 2, 1))
Debug.Print "MsgID"
End Sub


My extreme problem is that Request send by MyPc is correct or not as per message format given above and there is no Data_Arrival function calling.


Best Regards,
PARDEEP VISHWAKARMA
Pardeep

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.