Dear all;
See if you can guide here
(1) My understanding of the hostname is the local name of the machine or IP address which we get it by "netstart an" on the CMD prompt. Now when sending serial data to the other device on the same network which one of the pairs do we use?
(1) Hostname; Port number (All from source)
(2) Hostname (local) : port number ( destination)
For example in the VBA parameters below how do we go about it?
See if you can guide here
(1) My understanding of the hostname is the local name of the machine or IP address which we get it by "netstart an" on the CMD prompt. Now when sending serial data to the other device on the same network which one of the pairs do we use?
(1) Hostname; Port number (All from source)
(2) Hostname (local) : port number ( destination)
For example in the VBA parameters below how do we go about it?
Code:
Public Function ConnectServer(ByVal Hostname As String, ByVal PortNumber As Integer) As Integer
Dim StartUpInfo As WSAData
'Version 1.1 (1*256 + 1) = 257
'version 2.0 (2*256 + 0) = 512
'Get WinSock version
'Initialize Winsock DLL
x = WSAStartup(257, StartUpInfo)
Dim I_SocketAddress As sockaddr_in
Dim ipAddress As Long
ipAddress = inet_addr(Hostname) '...........(1)
'Create a new socket
socketId = socket(AF_INET, SOCK_STREAM, 0) '
If socketId = SOCKET_ERROR Then '
MsgBox ("ERROR: socket = " + Str$(socketId)) '...........(2)
OpenSocket = COMMAND_ERROR '
GoTo end1
End If '
'Open a connection to a server
I_SocketAddress.sin_family = AF_INET '
I_SocketAddress.sin_port = htons(PortNumber) '...........(3)
I_SocketAddress.sin_addr = ipAddress '
I_SocketAddress.sin_zero = String$(8, 0) '
x = Connect(socketId, I_SocketAddress, Len(I_SocketAddress)) '
If socketId = SOCKET_ERROR Then '
MsgBox ("ERROR: connect = " + Str$(x)) '..(4)
OpenSocket = COMMAND_ERROR '
Else
OpenSocket = socketId
End If
end1:
End Function[CODE]
Any assistance will be highly appreciated
Call ConnectServer("IP Address": Port Number)
Last edited: