http://doc.xceedsoft.com/products/Winsock/sources/timeclient_sample_application_(visual_basic_6).htm states: (The TimeClient sample sends a time request to specific server or broadcasts the time request on a "local network".)
The following is the source, & works fine on localhost. All I want is to be able to communicate via the internet... not just localhost or network.
please look at it, and change the code to allow internet workabillity. Just let me know what you would change. It is a registration form that needs to be able to talk to a licensing server accross the internet.
Private Sub Form_Load()
wskResolve.RemoteHost = "DomainName.com"
wskResolve.RemotePort = "80"
wskResolve.Connect
Set m_xTransferEvents = New AddressedByteTransferEvents
Dim xProtocols As New Protocols
Dim xProtocol As Protocol
Set xProtocol = xProtocols.GetProtocol(wafInet, wstDatagram, wptIP_UDP)
Dim xSocketFactory As New SocketFactory
Set m_xSocket = xSocketFactory.CreateConnectionlessSocket(xProtocol, 0)
Call m_xSocket.AddressedByteTransferAdvise(m_xTransferEvents, wtaAdviseReceivedAlways)
End Sub
Private Sub btGo_Click()
Timer3.Enabled = False
elFlood.FloodPercent = 0 Mod 101
elFlood.Caption = elFlood.FloodPercent & " %"
xI_v_GT 'anti debug initialize
'I have the following added right after "Option Explicit" at the top of the code page.
' Dim xAddressManager As New AddressManager
' Dim xAddresses As Addresses
' Dim xAddress As InetAddress
' Dim WithEvents m_xTransferEvents As AddressedByteTransferEvents
' Dim m_xSocket As ConnectionlessSocket
xI_v 'anti debug check
On Error Resume Next
Set xAddresses = xAddressManager.GetAddressesFromHostName(txtRemoteAddress, wnsDNS)
On Error GoTo 0
xI_v 'anti debug check
If xAddresses Is Nothing Then
Set xAddress = xAddressManager.GetAddressFromString(txtRemoteAddress & ":42741", wafInet)
xI_v 'anti debug check
ElseIf xAddresses.Count = 0 Then
Set xAddress = xAddressManager.GetAddressFromString(txtRemoteAddress & ":42741", wafInet)
xI_v 'anti debug check
Else
Set xAddress = xAddresses(1)
xAddress.Port = 42741
xI_v 'anti debug check
End If
m_xSocket.BroadcastEnabled = False
xI_v 'anti debug check
Call lstLog.AddItem("Sending request... ")
xI_v 'anti debug check
Dim cDummy(0) As Byte
cDummy(0) = 255
xI_v 'anti debug check
If isD = True Then Exit Sub 'secondary debug check
Call m_xSocket.SendBytesTo(xAddress, cSendSYS_IDToServer(GSID, MBSN, txtCustomerID.Text), wsoNone)
cmdlisten_Click
End Sub
'this is the hostname resolver i added.
'it returns the ip address only.
'txtRemoteAddress is assigned the result.
Private Sub wskResolve_Connect()
tmrOut.Enabled = False
txtRemoteAddress = wskResolve.RemoteHostIP
wskResolve.Close
btGo.Enabled = True
End Sub
'TimeOut
Private Sub tmrOut_Timer()
wskResolve.Close
tmrOut.Enabled = False
btGo.Enabled = True
MsgBox "The license Server is in the middle of a refresh..." & vbCrLf & vbCrLf & "Try to register again in a few minutes."
End Sub
'Start Listening for server response
Private Sub cmdlisten_Click()
wskT1.Close
wskT1.LocalPort = 30331
wskT1.Listen
AddStat "Listening"
End Sub
Public Sub AddStat(message As String)
lblstatus.Caption = message
End Sub
ps: I used the TimeClient, & TimeServer sample apps as a template, & did not change their core communication scripting. I just changed the port number, & added a small routine to resolve a domain name to its ip address... & passed the resulting ip to "txtRemoteAddress".