Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

winsock port 1200 problem

Status
Not open for further replies.

baran121

Programmer
Sep 8, 2005
337
TR
hi i am new user for winsock.

in my code with winsock i connect to 672 port, but i couldnt connect to 1200 port.
i can connect with hyperterminal port=672 or port=1200
plese help me.

there is my code down.

Private Sub cmdConnect_Click()
On Error GoTo hata_g

If cmdConnect.Caption = "Connect" Then
sockMain.Close
sockMain.Connect txtHost.Text, txtPort.Text
cmdConnect.Caption = "DisConnect"
MsgBox "Connected"
Else
sockMain.Close
cmdConnect.Caption = "Connect"
MsgBox "DisConnected"
End If

Exit Sub

hata_g:
MsgBox Err.Description
End Sub


Private Sub senddata_winsock()
dim strsend as string

strsend = "STP100" & vbTab & "100" & vbTab & "5" & vbCrLf
sockMain.SendData strsend
strsend = "GO" & vbCrLf
sockMain.SendData strsend
End Sub

 
What do you have at the receiving end?
You have to use the Connectionrequest routine at the other end for the connection to be completed. Hyperterminal probably does this.
Eg
Code:
'At receiving end
Private Sub Winsock1_ConnectionRequest(ByVal RequestID As Long)
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.Accept RequestID
End Sub
See other examples of this and the example in VB6 help

Should have something like this

Better to say
Code:
'Connecting
If SendMain.state<> sckConnected then SendMain.close  'in case of existing error
Sendmain.Connect txtHost.Text, txtPort.Text
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top