| | |
Help in winsock connection pls!
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
a i have a existing project here, it's a Cafe management for computer shops..
my problem is with the connection..
when is try to send a packet to the client..
the client wont react...
i dont know if the client side just cant receive the packets the server send..
or
the server didn't send the packet properly..
i been trouble with this for days..
since.. i cant detect the problem..
here the code for the send-button on the server side
and here's for the client side
pls help me
my problem is with the connection..
when is try to send a packet to the client..
the client wont react...
i dont know if the client side just cant receive the packets the server send..
or
the server didn't send the packet properly..
i been trouble with this for days..
since.. i cant detect the problem..
here the code for the send-button on the server side
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub imgComputingG_Click(Index As Integer) Dim stSQL As String Dim stTimeIn As String On Error GoTo Err_Handling If MsgBox("Start Unit#" & lblUnitNo(Index).Caption & " Timer?", vbQuestion + vbYesNo, "Start Timer") = vbYes Then Screen.MousePointer = vbHourglass 'bypass Sock.RemoteHost = "PC4" 'UnitPanel(Index).Tag Sock.SendData "1" stTimeIn = Format$(Now, "mm/dd/yyyy hh:mm ampm") stSQL = "UPDATE UnitLocStats set Status = 'A'," stSQL = stSQL & " StartDateTime = #" & stTimeIn & "#" stSQL = stSQL & " Where Unit = " & Str2Fld(lblUnitNo(Index).Caption) gDB.Execute stSQL lblUnitNo(Index).ForeColor = vbWhite lblDateCaption(Index).ForeColor = vbCyan lblStartTime(Index).ForeColor = vbWhite lblStartTime(Index).Caption = stTimeIn imgComputing(Index).PictureAnimationEnabled = True imgComputing(Index).Visible = True imgComputingG(Index).Visible = False UnitPanel(Index).Refresh Screen.MousePointer = vbDefault End If Exit Sub Err_Handling: Screen.MousePointer = vbDefault If Err.Number = 438 Or Err.Number = 10014 Then MsgBox "Workstation currently unavailable ...", vbInformation, "Unavailable" Else MsgBox Err.Number & " - " & Err.Description & "...", vbInformation, "Error Encountered" End If End Sub
and here's for the client side
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub Form_Load() Dim stCompName As String Dim stHostComputer As String Dim stHostPath As String Dim stStatus As String Dim stStartTime As String Dim lMins As Long Left = 0 Top = 0 Sock.RemoteHost = GetSetting(App.Title, "Settings", "HostComputer", "SNAKE-EYES") Sock.RemotePort = 1001 Sock.Bind 1002 stCompName = GetSetting(App.Title, "Settings", "ComputerName", vbNullString) stHostComputer = GetSetting(App.Title, "Settings", "HostComputer", vbNullString) stHostPath = GetSetting(App.Title, "Settings", "DBPath", "C:\Projects\TMS\TMS.MDB") If stCompName = vbNullString Or stHostComputer = vbNullString Or stHostPath = vbNullString Then frmSettings.Show vbModal End If stStatus = GetSetting(App.Title, "Settings", "Status", "Locked") stStartTime = GetSetting(App.Title, "Settings", "StartTime", vbNullString) If stStatus = "Locked" Then Call LockWorkStation Else lMins = CLng((Now - CDate(stStartTime)) * 1440) If lMins >= 60 Then mbyHrs = CByte(lMins / 60) mbyMins = lMins Mod 60 mbySecs = 0 Else mbyMins = lMins End If Timer1.Enabled = True End If End Sub
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub Sock_DataArrival(ByVal bytesTotal As Long) Dim stData As String On Error GoTo Err_Handler Sock.GetData stData Select Case Mid(stData, 1, 1) Case "0" 'Lock Workstation and Stop Timer Timer1.Enabled = False Call LockWorkStation Call SaveSetting(App.Title, "Settings", "Status", "Locked") Case "1" 'Unlock Workstation and Start Timer Call UnlockWorkStation Call Reset Call SaveSetting(App.Title, "Settings", "Status", "Unlocked") Call SaveSetting(App.Title, "Settings", "StartTime", Now) Case "2" 'Confirm Order MsgBox "Thankyou !!! Your Order(s) and Message have been received...", vbInformation, "Orders Confirmed" Unload frmMenuToday Case "3" 'Message cmdOrder.PlaySoundFile "Notice.wav" MsgBox Mid$(stData, 2), vbInformation + vbOKOnly, "Message from Counter" Case "4" 'Lock Workstation w/o stopping Timer Settings Call LockWorkStation Case "5" 'Unlock Workstation w/o stopping Timer Settings Call UnlockWorkStation Case "6" 'Shutdown Workstation Call ShutdownWorkstation End Select Exit Sub Err_Handler: Screen.MousePointer = vbDefault MsgBox Err.Number & " - " & Err.Description & " ...", "Error Encountered" End Sub
pls help me
•
•
Join Date: Nov 2007
Posts: 140
Reputation:
Solved Threads: 15
Does the client connect to the server OK first of all?
If you cant connect, then its likely to be related to a networking issue (i.e. a firewall stopping the connection going through).
Are you using TCP or UDP for the connection also? UDP would use the .Bind command (from my experience) whereas the TCP would use .Listen at the receiving end (the server where the clients connect to) and .Connect at the initiating end (the client which is connecting to a server).
If you cant connect, then its likely to be related to a networking issue (i.e. a firewall stopping the connection going through).
Are you using TCP or UDP for the connection also? UDP would use the .Bind command (from my experience) whereas the TCP would use .Listen at the receiving end (the server where the clients connect to) and .Connect at the initiating end (the client which is connecting to a server).
•
•
•
•
Are you using TCP or UDP for the connection also?
when ever i try to send a packet to the client (ex, Start the time of the client)
there's no "Data_arrival" happening on the client side..
also can you pls sir explain to me the .bind command? thx for the reply sir!
•
•
Join Date: Nov 2007
Posts: 140
Reputation:
Solved Threads: 15
.Bind is used in UDP to "attach" the application to a particular local port. Whereas .Listen is used in TCP to allow clients to connect according to the LocalPort provided.
There is a bit more detail about it here: http://msdn.microsoft.com/en-us/libr...09(VS.60).aspx
I've not used UDP much, only when making a game server query tool a while back, so I have referred to the link I gave you just then and I think that you would need to include the RemotePort in the server code, and also bind the control to a local port even though it is classed as the server.
The MSDN link advises that the RemoteHost, RemotePort and Bind are to be used on both client and server.
Hope that helps...
There is a bit more detail about it here: http://msdn.microsoft.com/en-us/libr...09(VS.60).aspx
I've not used UDP much, only when making a game server query tool a while back, so I have referred to the link I gave you just then and I think that you would need to include the RemotePort in the server code, and also bind the control to a local port even though it is classed as the server.
The MSDN link advises that the RemoteHost, RemotePort and Bind are to be used on both client and server.
Hope that helps...
![]() |
Similar Threads
- Connected to Network but can't get the internet to work properly (Windows NT / 2000 / XP)
- Problem when connecting with winsock through router (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: mshflexgrid
- Next Thread: How to install SQL server 2000
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





