IM having problems connecting with connecting using TCP/IP over a network
using winsock. Can anyone find a problem with this code:
This is the sever part:
Private Sub socket_ConnectionRequest(Index As Integer, ByVal requestID As
Long)
If Index = 0 Then
iSockets = iSockets + 1
Load socket(iSockets)
socket(iSockets).LocalPort = 120
socket(iSockets).Accept requestID
End If
End Sub
Private Sub socket_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim udtNewNote As udtNote
Dim intFileNum As Integer
Dim lRecLength As Long
Dim lLastRecord As Long
Dim noteArray(0 To gcLimit) As udtNote
Dim lNoteArrayCount As Long
Dim strValue As String
Dim strMessage As String
socket(Index).GetData strMessage
CopyString udtNewNote, strMessage, Len(udtNewNote)
MsgBox "You have a new note!", vbOKOnly, "PC-Notes"
'Write note to file
lNoteArrayCount = 0
lRecLength = Len(noteArray(0))
intFileNum = FreeFile
Open App.Path & "\notes.dat" For Random As intFileNum Len = lRecLength
'Find last record in the file
lLastRecord = FileLen(App.Path & "\notes.dat") / lRecLength
gCurrentNoteRecord = lLastRecord + 1
If gCurrentNoteRecord = 0 Then
gCurrentNoteRecord = 1
End If
Put intFileNum, gCurrentNoteRecord, udtNewNote
End Sub
--------And this is the client part(Both these parts are in the same
program. Does this --------matter)
newNote.caller = txtCaller.Text
newNote.date = txtDate.Text
newNote.subject = txtSubject.Text
newNote.time = txtTime.Text
newNote.contact.name = cboContact.Text
newNote.contact.email = txtArrayCompanyDetails(3).Text
newNote.contact.fax = txtArrayCompanyDetails(1).Text
newNote.contact.mobile = txtArrayCompanyDetails(2).Text
newNote.contact.phone = txtArrayCompanyDetails(1).Text
newNote.note = txtMessage.Text
newNote.completed = False
If Not (cboUsers.Text = "") Then
CopyMemory bytNote(0), newNote, Len(newNote)
strMessage = Left(StrConv(bytNote, vbUnicode), Len(newNote))
Winsock.Protocol = sckTCPProtocol
Winsock.RemotePort = 120
Winsock.RemoteHost = getIPAddress
Winsock.Connect
Winsock.SendData (strMessage)
End If
-----Procedures in module
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As Any,
lpvSrc As Any, ByVal dwSize As Long)
Declare Sub CopyString Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As Any,
ByVal strSrc As String, ByVal dwSize As Long)
-----I'm way past my deadline on this and could do with all the help I can
get.