RUN-TIME ERROR '40006'

WRONG PROTOCOL OR OR CONNCETION STATE FOR THE REQUEST TRANSACTION OR REQUEST.

that is my problem,, here is my code that has an error.

Private Sub Text2_Keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List1.AddItem (Text2.Text)

Winsock1.SendData Text2.Text

Combo1.SetFocus
End If
End Sub

please help me.. im making client/server schedule board. so please help me to solve my problem..

i actually need is to transfer the data to the other pc,. what might be missing??

RUN-TIME ERROR '40006'

WRONG PROTOCOL OR OR CONNCETION STATE FOR THE REQUEST TRANSACTION OR REQUEST.

that is my problem,, here is my code that has an error.

Private Sub Text2_Keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List1.AddItem (Text2.Text)

Winsock1.SendData Text2.Text

Combo1.SetFocus
End If
End Sub

please help me.. im making client/server schedule board. so please help me to solve my problem..

You need to make sure that you are acutally connected before trying to send.

Try the following code

Private Sub Text2_Keypress(keyascii As Integer)
    If keyascii = 13 Then
        keyascii = 0
        List1.AddItem (Text2.Text)

        if winsock1.state = sckconnected then
            Winsock1.SendData Text2.Text
        else
            msgbox "Winsock is not connected"
        end if

        Combo1.SetFocus
    End If
End Sub

Thanks bushman but.. still cant connect..
RUN-TIME ERROR '40006'
the only new is "Winsock is not connected" i need a solution to send data to other pc.. because im working on a client/server schedule board... please please help me...

There is the root cause of your problem

how is the client connecting to the server?

Can you provide just the clinet connecting code and the server listening and connection request code. That might help me to pin point your problem

This is the Whole Code of my Project...
Please Please Help me bushman to fix the problem...


CLIENT

Private Sub Form_Load()

Winsock1.LocalPort = "165"
Winsock1.Listen
Size = 0

Winsock2.LocalPort = "166"
Winsock2.Listen

Winsock3.LocalPort = "167"
Winsock3.Listen

Winsock4.LocalPort = "168"
Winsock4.Listen

Winsock5.LocalPort = "169"
Winsock5.Listen


Winsock6.LocalPort = "170"
Winsock6.Listen

Winsock7.LocalPort = "171"
Winsock7.Listen

Winsock8.LocalPort = "172"
Winsock8.Listen

Winsock9.LocalPort = "173"
Winsock9.Listen

Winsock10.LocalPort = "174"
Winsock10.Listen

Winsock11.LocalPort = "175"
Winsock11.Listen

Winsock12.LocalPort = "176"
Winsock12.Listen

Winsock13.LocalPort = "177"
Winsock13.Listen


Winsock14.LocalPort = "178"
Winsock14.Listen

Winsock15.LocalPort = "179"
Winsock15.Listen

Winsock16.LocalPort = "180"
Winsock16.Listen

Winsock17.LocalPort = "181"
Winsock17.Listen

Winsock18.LocalPort = "182"
Winsock18.Listen

Winsock19.LocalPort = "183"
Winsock19.Listen

Winsock20.LocalPort = "184"
Winsock20.Listen

Winsock21.LocalPort = "185"
Winsock21.Listen


Winsock22.LocalPort = "186"
Winsock22.Listen

Winsock23.LocalPort = "187"
Winsock23.Listen

Winsock24.LocalPort = "188"
Winsock24.Listen

Winsock25.LocalPort = "189"
Winsock25.Listen


Winsock26.LocalPort = "190"
Winsock26.Listen

Winsock27.LocalPort = "191"
Winsock27.Listen

Winsock28.LocalPort = "192"
Winsock28.Listen

Winsock29.LocalPort = "193"
Winsock29.Listen


Winsock30.LocalPort = "194"
Winsock30.Listen

Winsock31.LocalPort = "195"
Winsock31.Listen

Winsock32.LocalPort = "196"
Winsock32.Listen
End Sub

Private Sub mnu_exit_Click()
Winsock1.Close
Winsock2.Close
Winsock3.Close
Winsock4.Close
Winsock5.Close
Winsock6.Close
Winsock7.Close
Winsock8.Close
Winsock9.Close
Winsock10.Close
Winsock11.Close
Winsock12.Close
Winsock13.Close
Winsock14.Close
Winsock15.Close
Winsock16.Close
Winsock17.Close
Winsock18.Close
Winsock19.Close
Winsock20.Close
Winsock21.Close
Winsock22.Close
Winsock23.Close
Winsock24.Close
Winsock25.Close
Winsock26.Close
Winsock27.Close
Winsock28.Close
Winsock29.Close
Winsock30.Close
Winsock31.Close
Winsock32.Close
End
End Sub
Private Sub winsock1_ConnectionRequest(ByVal idrequest As Long)
Winsock1.Close
Winsock1.Accept idrequest
End Sub

Private Sub winsock1_dataarrival(ByVal bytestotal As Long)

Dim cht As String
Winsock1.GetData cht, vbString
Label1.Caption = cht

End Sub
Private Sub winsock2_connectionrequest(ByVal idrequest As Long)
Winsock2.Close
Winsock2.Accept idrequest
End Sub
Private Sub winsock2_dataarrival(ByVal bytestotal As Long)
Dim cht2 As String
Winsock2.GetData cht2, vbString
Label2.Caption = cht2

End Sub
Private Sub winsock3_ConnectionRequest(ByVal idrequest As Long)
Winsock3.Close
Winsock3.Accept idrequest
End Sub

Private Sub winsock3_dataarrival(ByVal bytestotal As Long)

Dim cht3 As String
Winsock3.GetData cht3, vbString
Label3.Caption = cht3

End Sub
Private Sub winsock4_ConnectionRequest(ByVal idrequest As Long)
Winsock4.Close
Winsock4.Accept idrequest
End Sub

Private Sub winsock4_dataarrival(ByVal bytestotal As Long)

Dim cht4 As String
Winsock4.GetData cht4, vbString
Label4.Caption = cht4

End Sub
Private Sub winsock5_ConnectionRequest(ByVal idrequest As Long)
Winsock5.Close
Winsock5.Accept idrequest
End Sub

Private Sub winsock5_dataarrival(ByVal bytestotal As Long)

Dim cht5 As String
Winsock5.GetData cht5, vbString
Label5.Caption = cht5

End Sub
Private Sub winsock6_ConnectionRequest(ByVal idrequest As Long)
Winsock6.Close
Winsock6.Accept idrequest
End Sub

Private Sub winsock6_dataarrival(ByVal bytestotal As Long)

Dim cht6 As String
Winsock6.GetData cht6, vbString
Label6.Caption = cht6

End Sub
Private Sub winsock7_ConnectionRequest(ByVal idrequest As Long)
Winsock7.Close
Winsock7.Accept idrequest
End Sub

Private Sub winsock7_dataarrival(ByVal bytestotal As Long)

Dim cht7 As String
Winsock7.GetData cht7, vbString
Label7.Caption = cht7

End Sub
Private Sub winsock8_ConnectionRequest(ByVal idrequest As Long)
Winsock8.Close
Winsock8.Accept idrequest
End Sub

Private Sub winsock8_dataarrival(ByVal bytestotal As Long)

Dim cht8 As String
Winsock8.GetData cht8, vbString
Label8.Caption = cht8

End Sub
Private Sub winsock9_ConnectionRequest(ByVal idrequest As Long)
Winsock9.Close
Winsock9.Accept idrequest
End Sub

Private Sub winsock9_dataarrival(ByVal bytestotal As Long)

Dim cht9 As String
Winsock9.GetData cht9, vbString
Label9.Caption = cht9

End Sub
Private Sub winsock10_connectionrequest(ByVal idrequest As Long)
Winsock10.Close
Winsock10.Accept idrequest
End Sub
Private Sub winsock10_dataarrival(ByVal bytestotal As Long)
Dim cht10 As String
Winsock10.GetData cht10, vbString
Label10.Caption = cht10

End Sub
Private Sub winsock11_ConnectionRequest(ByVal idrequest As Long)
Winsock11.Close
Winsock11.Accept idrequest
End Sub

Private Sub winsock11_dataarrival(ByVal bytestotal As Long)

Dim cht11 As String
Winsock11.GetData cht11, vbString
Label11.Caption = cht11

End Sub
Private Sub winsock12_ConnectionRequest(ByVal idrequest As Long)
Winsock12.Close
Winsock12.Accept idrequest
End Sub

Private Sub winsock12_dataarrival(ByVal bytestotal As Long)

Dim cht12 As String
Winsock12.GetData cht12, vbString
Label12.Caption = cht12

End Sub
Private Sub winsock13_ConnectionRequest(ByVal idrequest As Long)
Winsock13.Close
Winsock13.Accept idrequest
End Sub

Private Sub winsock13_dataarrival(ByVal bytestotal As Long)

Dim cht13 As String
Winsock13.GetData cht13, vbString
Label13.Caption = cht13

End Sub
Private Sub winsock14_ConnectionRequest(ByVal idrequest As Long)
Winsock14.Close
Winsock14.Accept idrequest
End Sub

Private Sub winsock14_dataarrival(ByVal bytestotal As Long)

Dim cht14 As String
Winsock14.GetData cht14, vbString
Label14.Caption = cht14

End Sub
Private Sub winsock15_ConnectionRequest(ByVal idrequest As Long)
Winsock15.Close
Winsock15.Accept idrequest
End Sub

Private Sub winsock15_dataarrival(ByVal bytestotal As Long)

Dim cht15 As String
Winsock15.GetData cht15, vbString
Label15.Caption = cht15

End Sub
Private Sub winsock16_ConnectionRequest(ByVal idrequest As Long)
Winsock16.Close
Winsock16.Accept idrequest
End Sub

Private Sub winsock16_dataarrival(ByVal bytestotal As Long)

Dim cht16 As String
Winsock16.GetData cht16, vbString
Label16.Caption = cht16

End Sub
Private Sub winsock17_ConnectionRequest(ByVal idrequest As Long)
Winsock17.Close
Winsock17.Accept idrequest
End Sub

Private Sub winsock17_dataarrival(ByVal bytestotal As Long)

Dim cht17 As String
Winsock17.GetData cht17, vbString
Label17.Caption = cht17

End Sub
Private Sub winsock18_connectionrequest(ByVal idrequest As Long)
Winsock18.Close
Winsock18.Accept idrequest
End Sub
Private Sub winsock18_dataarrival(ByVal bytestotal As Long)
Dim cht18 As String
Winsock18.GetData cht18, vbString
Label18.Caption = cht18

End Sub
Private Sub winsock19_ConnectionRequest(ByVal idrequest As Long)
Winsock19.Close
Winsock19.Accept idrequest
End Sub

Private Sub winsock19_dataarrival(ByVal bytestotal As Long)

Dim cht19 As String
Winsock19.GetData cht19, vbString
Label19.Caption = cht19

End Sub
Private Sub winsock20_ConnectionRequest(ByVal idrequest As Long)
Winsock20.Close
Winsock20.Accept idrequest
End Sub

Private Sub winsock20_dataarrival(ByVal bytestotal As Long)

Dim cht20 As String
Winsock20.GetData cht20, vbString
Label20.Caption = cht20

End Sub
Private Sub winsock21_ConnectionRequest(ByVal idrequest As Long)
Winsock21.Close
Winsock21.Accept idrequest
End Sub

Private Sub winsock21_dataarrival(ByVal bytestotal As Long)

Dim cht21 As String
Winsock21.GetData cht21, vbString
Label21.Caption = cht21

End Sub
Private Sub winsock22_ConnectionRequest(ByVal idrequest As Long)
Winsock22.Close
Winsock22.Accept idrequest
End Sub

Private Sub winsock22_dataarrival(ByVal bytestotal As Long)

Dim cht22 As String
Winsock22.GetData cht22, vbString
Label22.Caption = cht22

End Sub
Private Sub winsock23_ConnectionRequest(ByVal idrequest As Long)
Winsock23.Close
Winsock23.Accept idrequest
End Sub

Private Sub winsock23_dataarrival(ByVal bytestotal As Long)

Dim cht23 As String
Winsock23.GetData cht23, vbString
Label23.Caption = cht23

End Sub
Private Sub winsock24_ConnectionRequest(ByVal idrequest As Long)
Winsock24.Close
Winsock24.Accept idrequest
End Sub
Private Sub winsock24_dataarrival(ByVal bytestotal As Long)

Dim cht24 As String
Winsock24.GetData cht24, vbString
Label24.Caption = cht24

End Sub
Private Sub winsock25_ConnectionRequest(ByVal idrequest As Long)
Winsock25.Close
Winsock25.Accept idrequest
End Sub
Private Sub winsock25_dataarrival(ByVal bytestotal As Long)

Dim cht25 As String
Winsock25.GetData cht25, vbString
Label25.Caption = cht25

End Sub
Private Sub winsock26_connectionrequest(ByVal idrequest As Long)
Winsock26.Close
Winsock26.Accept idrequest
End Sub
Private Sub winsock26_dataarrival(ByVal bytestotal As Long)
Dim cht26 As String
Winsock26.GetData cht26, vbString
Label26.Caption = cht26

End Sub
Private Sub winsock27_ConnectionRequest(ByVal idrequest As Long)
Winsock27.Close
Winsock27.Accept idrequest
End Sub

Private Sub winsock27_dataarrival(ByVal bytestotal As Long)

Dim cht27 As String
Winsock27.GetData cht27, vbString
Label27.Caption = cht27

End Sub
Private Sub winsock28_ConnectionRequest(ByVal idrequest As Long)
Winsock28.Close
Winsock28.Accept idrequest
End Sub

Private Sub winsock28_dataarrival(ByVal bytestotal As Long)

Dim cht28 As String
Winsock28.GetData cht28, vbString
Label28.Caption = cht28

End Sub
Private Sub winsock29_ConnectionRequest(ByVal idrequest As Long)
Winsock29.Close
Winsock29.Accept idrequest
End Sub

Private Sub winsock29_dataarrival(ByVal bytestotal As Long)

Dim cht29 As String
Winsock29.GetData cht29, vbString
Label29.Caption = cht29

End Sub
Private Sub winsock30_ConnectionRequest(ByVal idrequest As Long)
Winsock30.Close
Winsock30.Accept idrequest
End Sub

Private Sub winsock30_dataarrival(ByVal bytestotal As Long)

Dim cht30 As String
Winsock30.GetData cht30, vbString
Label30.Caption = cht30

End Sub
Private Sub winsock31_ConnectionRequest(ByVal idrequest As Long)
Winsock31.Close
Winsock31.Accept idrequest
End Sub

Private Sub winsock31_dataarrival(ByVal bytestotal As Long)

Dim cht31 As String
Winsock31.GetData cht31, vbString
Label31.Caption = cht31

End Sub
Private Sub winsock32_ConnectionRequest(ByVal idrequest As Long)
Winsock32.Close
Winsock32.Accept idrequest
End Sub

Private Sub winsock32_dataarrival(ByVal bytestotal As Long)

Dim cht32 As String
Winsock32.GetData cht32, vbString
Label32.Caption = cht32

End Sub


SERVER

Private Sub Combo1_Click()
List2.AddItem (Combo1.Text)

Winsock2.SendData Combo1.Text
End Sub

Private Sub Combo1_Keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List2.AddItem (Combo1.Text)

Winsock2.SendData Combo1.Text

Combo2.SetFocus
End If
End Sub

Private Sub Combo10_Click()
List14.AddItem (Combo10.Text)

Winsock14.SendData Combo10.Text
End Sub

Private Sub Combo10_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List14.AddItem (Combo10.Text)

Winsock14.SendData Combo10.Text

Combo11.SetFocus
End If
End Sub

Private Sub Combo11_Click()
List15.AddItem (Combo11.Text)

Winsock15.SendData Combo11.Text
End Sub

Private Sub Combo11_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List15.AddItem (Combo11.Text)

Winsock15.SendData Combo11.Text

Combo12.SetFocus
End If
End Sub

Private Sub Combo12_Click()
List16.AddItem (Combo12.Text)

Winsock16.SendData Combo12.Text
End Sub

Private Sub Combo12_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List16.AddItem (Combo12.Text)

Winsock16.SendData Combo12.Text

Text6.SetFocus
End If
End Sub

Private Sub Combo13_Click()
List18.AddItem (Combo13.Text)

Winsock18.SendData Combo13.Text
End Sub

Private Sub Combo13_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List18.AddItem (Combo13.Text)

Winsock18.SendData Combo13.Text

Combo14.SetFocus
End If
End Sub

Private Sub Combo14_Click()
List19.AddItem (Combo14.Text)

Winsock19.SendData Combo14.Text
End Sub

Private Sub Combo14_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List19.AddItem (Combo14.Text)

Winsock19.SendData Combo14.Text

Combo15.SetFocus
End If
End Sub

Private Sub Combo15_Click()
List20.AddItem (Combo15.Text)

Winsock20.SendData Combo15.Text
End Sub

Private Sub Combo15_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List20.AddItem (Combo15.Text)

Winsock20.SendData Combo15.Text

Text7.SetFocus
End If
End Sub

Private Sub Combo16_Click()
List22.AddItem (Combo16.Text)

Winsock22.SendData Combo16.Text
End Sub

Private Sub Combo16_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List22.AddItem (Combo16.Text)

Winsock22.SendData Combo16.Text

Combo17.SetFocus
End If
End Sub

Private Sub Combo17_Click()
List23.AddItem (Combo17.Text)

Winsock23.SendData Combo17.Text
End Sub

Private Sub Combo17_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List23.AddItem (Combo17.Text)

Winsock23.SendData Combo17.Text

Combo18.SetFocus
End If
End Sub

Private Sub Combo18_Click()
List24.AddItem (Combo18.Text)

Winsock24.SendData Combo18.Text
End Sub

Private Sub Combo18_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List24.AddItem (Combo18.Text)

Winsock24.SendData Combo18.Text

Text8.SetFocus
End If
End Sub

Private Sub Combo19_Click()
List26.AddItem (Combo19.Text)

Winsock26.SendData Combo19.Text

End Sub

Private Sub Combo19_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List26.AddItem (Combo19.Text)

Winsock26.SendData Combo19.Text

Combo20.SetFocus
End If
End Sub

Private Sub Combo2_Click()
List3.AddItem (Combo2.Text)

Winsock3.SendData Combo2.Text
End Sub

Private Sub Combo2_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List3.AddItem (Combo2.Text)

Winsock3.SendData Combo2.Text

Combo3.SetFocus
End If
End Sub

Private Sub Combo20_Click()
List27.AddItem (Combo20.Text)

Winsock27.SendData Combo20.Text
End Sub

Private Sub Combo20_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List27.AddItem (Combo20.Text)

Winsock27.SendData Combo20.Text

Combo21.SetFocus
End If
End Sub

Private Sub Combo21_Click()
List28.AddItem (Combo21.Text)

Winsock28.SendData Combo21.Text
End Sub

Private Sub Combo21_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List28.AddItem (Combo21.Text)

Winsock28.SendData Combo21.Text

Text9.SetFocus
End If
End Sub

Private Sub Combo22_Click()
List30.AddItem (Combo22.Text)

Winsock30.SendData Combo22.Text
End Sub

Private Sub Combo22_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List30.AddItem (Combo22.Text)

Winsock30.SendData Combo22.Text

Combo23.SetFocus
End If
End Sub

Private Sub Combo23_Click()
List31.AddItem (Combo23.Text)

Winsock31.SendData Combo23.Text
End Sub

Private Sub Combo23_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List31.AddItem (Combo23.Text)

Winsock31.SendData Combo23.Text

Combo24.SetFocus
End If
End Sub

Private Sub Combo24_Click()
List32.AddItem (Combo24.Text)

Winsock32.SendData Combo24.Text
End Sub

Private Sub Combo24_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List32.AddItem (Combo24.Text)

Winsock32.SendData Combo24.Text

Text2.SetFocus
End If
End Sub

Private Sub Combo3_Click()
List4.AddItem (Combo3.Text)

Winsock4.SendData Combo3.Text
End Sub

Private Sub Combo3_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List4.AddItem (Combo3.Text)

Winsock4.SendData Combo3.Text

Text3.SetFocus
End If
End Sub

Private Sub Combo4_Click()
List6.AddItem (Combo4.Text)

Winsock6.SendData Combo4.Text
End Sub

Private Sub Combo4_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List6.AddItem (Combo4.Text)

Winsock6.SendData Combo4.Text

Combo5.SetFocus
End If
End Sub

Private Sub Combo5_Click()
List7.AddItem (Combo5.Text)

Winsock7.SendData Combo5.Text
End Sub

Private Sub Combo5_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List7.AddItem (Combo5.Text)

Winsock7.SendData Combo5.Text

Combo6.SetFocus
End If
End Sub

Private Sub Combo6_Click()
List8.AddItem (Combo6.Text)

Winsock8.SendData Combo6.Text
End Sub

Private Sub Combo6_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List8.AddItem (Combo6.Text)

Winsock8.SendData Combo6.Text

Text4.SetFocus
End If
End Sub

Private Sub Combo7_Click()
List10.AddItem (Combo7.Text)

Winsock10.SendData Combo7.Text
End Sub

Private Sub Combo7_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List10.AddItem (Combo7.Text)

Winsock10.SendData Combo7.Text

Combo8.SetFocus
End If
End Sub

Private Sub Combo8_Click()
List11.AddItem (Combo8.Text)

Winsock11.SendData Combo8.Text
End Sub

Private Sub Combo8_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List11.AddItem (Combo8.Text)

Winsock11.SendData Combo8.Text

Combo9.SetFocus
End If
End Sub

Private Sub Combo9_Click()
List12.AddItem (Combo9.Text)

Winsock12.SendData Combo9.Text
End Sub

Private Sub Combo9_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List12.AddItem (Combo9.Text)

Winsock12.SendData Combo9.Text

Text5.SetFocus
End If
End Sub

Private Sub Command1_Click()
Winsock1.Connect Text3, "165"
Winsock2.Connect Text3, "166"
Winsock3.Connect Text3, "167"
Winsock4.Connect Text3, "168"
Winsock5.Connect Text3, "169"
Winsock6.Connect Text3, "170"
Winsock7.Connect Text3, "171"
Winsock8.Connect Text3, "172"
Winsock9.Connect Text3, "173"
Winsock10.Connect Text3, "174"
Winsock11.Connect Text3, "175"
Winsock12.Connect Text3, "176"
Winsock13.Connect Text3, "177"
Winsock14.Connect Text3, "178"
Winsock15.Connect Text3, "179"
Winsock16.Connect Text3, "180"
Winsock17.Connect Text3, "181"
Winsock18.Connect Text3, "182"
Winsock19.Connect Text3, "183"
Winsock20.Connect Text3, "184"
Winsock21.Connect Text3, "185"
Winsock22.Connect Text3, "186"
Winsock23.Connect Text3, "187"
Winsock24.Connect Text3, "188"
Winsock25.Connect Text3, "189"
Winsock26.Connect Text3, "190"
Winsock27.Connect Text3, "191"
Winsock28.Connect Text3, "192"
Winsock29.Connect Text3, "193"
Winsock30.Connect Text3, "194"
Winsock31.Connect Text3, "195"
Winsock32.Connect Text3, "196"

End Sub

Private Sub Command2_Click()
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Combo1.Text = ""
Combo2.Text = ""
Combo3.Text = ""
Combo4.Text = ""
Combo5.Text = ""
Combo6.Text = ""
Combo7.Text = ""
Combo8.Text = ""
Combo9.Text = ""
Combo10.Text = ""
Combo11.Text = ""
Combo12.Text = ""
Combo13.Text = ""
Combo14.Text = ""
Combo15.Text = ""
Combo16.Text = ""
Combo17.Text = ""
Combo18.Text = ""
Combo19.Text = ""
Combo20.Text = ""
Combo21.Text = ""
Combo22.Text = ""
Combo23.Text = ""
Combo24.Text = ""

End Sub

Private Sub Command6_Click()
Winsock1.Close
Winsock2.Close
Winsock3.Close
Winsock4.Close
Winsock5.Close
Winsock6.Close
Winsock7.Close
Winsock8.Close
Winsock9.Close
Winsock10.Close
Winsock11.Close
Winsock12.Close
Winsock13.Close
Winsock14.Close
Winsock15.Close
Winsock16.Close
Winsock17.Close
Winsock18.Close
Winsock19.Close
Winsock20.Close
Winsock21.Close
Winsock22.Close
Winsock23.Close
Winsock24.Close
Winsock25.Close
Winsock26.Close
Winsock27.Close
Winsock28.Close
Winsock29.Close
Winsock30.Close
Winsock31.Close
Winsock32.Close

End Sub

Private Sub mnu_exit_Click()
Winsock1.Close
Winsock2.Close
Winsock3.Close
Winsock4.Close
Winsock5.Close
Winsock6.Close
Winsock7.Close
Winsock8.Close
Winsock9.Close
Winsock10.Close
Winsock11.Close
Winsock12.Close
Winsock13.Close
Winsock14.Close
Winsock15.Close
Winsock16.Close
Winsock17.Close
Winsock18.Close
Winsock19.Close
Winsock20.Close
Winsock21.Close
Winsock22.Close
Winsock23.Close
Winsock24.Close
Winsock25.Close
Winsock26.Close
Winsock27.Close
Winsock28.Close
Winsock29.Close
Winsock30.Close
Winsock31.Close
Winsock32.Close

End
End Sub

Private Sub Text1_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
Winsock1.Connect Text3, "165"
Winsock2.Connect Text3, "166"
Winsock3.Connect Text3, "167"
Winsock4.Connect Text3, "168"
Winsock5.Connect Text3, "169"
Winsock6.Connect Text3, "170"
Winsock7.Connect Text3, "171"
Winsock8.Connect Text3, "172"
Winsock9.Connect Text3, "173"
Winsock10.Connect Text3, "174"
Winsock11.Connect Text3, "175"
Winsock12.Connect Text3, "176"
Winsock13.Connect Text3, "177"
Winsock14.Connect Text3, "178"
Winsock15.Connect Text3, "179"
Winsock16.Connect Text3, "180"
Winsock17.Connect Text3, "181"
Winsock18.Connect Text3, "182"
Winsock19.Connect Text3, "183"
Winsock20.Connect Text3, "184"
Winsock21.Connect Text3, "185"
Winsock22.Connect Text3, "186"
Winsock23.Connect Text3, "187"
Winsock24.Connect Text3, "188"
Winsock25.Connect Text3, "189"
Winsock26.Connect Text3, "190"
Winsock27.Connect Text3, "191"
Winsock28.Connect Text3, "192"
Winsock29.Connect Text3, "193"
Winsock30.Connect Text3, "194"
Winsock31.Connect Text3, "195"
Winsock32.Connect Text3, "196"

Text2.SetFocus
End If
End Sub

Private Sub Text2_Keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List1.AddItem (Text2.Text)

Winsock1.SendData Text2.Text

Combo1.SetFocus
End If
End Sub

Private Sub Text3_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List5.AddItem (Text3.Text)

Winsock5.SendData Text3.Text

Combo4.SetFocus
End If
End Sub

Private Sub Text4_keypress(keyascii As Integer)

If keyascii = 13 Then
keyascii = 0
List9.AddItem (Text4.Text)
Winsock9.SendData Text4.Text
Combo7.SetFocus
End If
End Sub

Private Sub Text5_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List13.AddItem (Text5.Text)

Winsock13.SendData Text5.Text

Combo10.SetFocus
End If
End Sub

Private Sub Text6_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List17.AddItem (Text6.Text)

Winsock17.SendData Text6.Text

Combo13.SetFocus
End If
End Sub

Private Sub Text7_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List21.AddItem (Text7.Text)

Winsock21.SendData Text7.Text

Combo16.SetFocus
End If
End Sub

Private Sub Text8_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List25.AddItem (Text8.Text)

Winsock25.SendData Text8.Text

Combo19.SetFocus
End If
End Sub

Private Sub Text9_keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List29.AddItem (Text9.Text)

Winsock29.SendData Text9.Text

Combo22.SetFocus
End If
End Sub

UN-TIME ERROR '40006'

WRONG PROTOCOL OR OR CONNCETION STATE FOR THE REQUEST TRANSACTION OR REQUEST.

that is my problem,, here is my code that has an error.

This is the code from server that have an error 40004

Private Sub Text2_Keypress(keyascii As Integer)
If keyascii = 13 Then
keyascii = 0
List1.AddItem (Text2.Text)

Winsock1.SendData Text2.Text

Combo1.SetFocus
End If
End Sub

///and this is the sample code for my client\\\

Private Sub Form_Load()

Winsock1.LocalPort = "165"
Winsock1.Listen
Size = 0

Winsock2.LocalPort = "166"
Winsock2.Listen

Winsock3.LocalPort = "167"
Winsock3.Listen

Winsock4.LocalPort = "168"
Winsock4.Listen
---------------------------------

Private Sub winsock1_ConnectionRequest(ByVal idrequest As Long)
Winsock1.Close
Winsock1.Accept idrequest
End Sub

Private Sub winsock1_dataarrival(ByVal bytestotal As Long)

Dim cht As String
Winsock1.GetData cht, vbString
Label1.Caption = cht

End Sub
Private Sub winsock2_connectionrequest(ByVal idrequest As Long)
Winsock2.Close
Winsock2.Accept idrequest
End Sub
Private Sub winsock2_dataarrival(ByVal bytestotal As Long)
Dim cht2 As String
Winsock2.GetData cht2, vbString
Label2.Caption = cht2

End Sub
Private Sub winsock3_ConnectionRequest(ByVal idrequest As Long)
Winsock3.Close
Winsock3.Accept idrequest
End Sub

Private Sub winsock3_dataarrival(ByVal bytestotal As Long)

Dim cht3 As String
Winsock3.GetData cht3, vbString
Label3.Caption = cht3

End Sub
Private Sub winsock4_ConnectionRequest(ByVal idrequest As Long)
Winsock4.Close
Winsock4.Accept idrequest
End Sub

Private Sub winsock4_dataarrival(ByVal bytestotal As Long)

Dim cht4 As String
Winsock4.GetData cht4, vbString
Label4.Caption = cht4

sorry for the bunch of code ehehehehehe
....hoping to fix my problem... thanks bushman

Whom do you expect to read all that code and solve your problem ?

em, ok

Lets try this one step at a time as I agree with debasisdas. Did you know that was 25 ms word pages

Questions for ya
Why do you need so many winsocks? (maybe a control array)
Do any of them connect?
Have you managed to use winsock before?
Have you tried working with just one winsock in this project before using multiple?

Yes..
I use many winsock because.. erlier i've try only one winsock to connect but only one textbox work, and the rest didnot work...
i dont know if they all connect. because it is my first time to use winsock.. hehehehe im only 1st year high school and my teacher gave me a project client server/server schedule board..

i tried already but as i've sad a while ago, its working but some of the fields in the server of my schedule board doesnt work..

yes.

i try to use many winsock because, the last i tried only 1 winsock only 1 one texbox send the data. the rest not affected..so that i used many winsock..
this is my first time to use winsock,, because im only a beginer programer in visual basic..
i tried 1 winsock but only one field affected that is text1 only... then i try to use multiple winsock and i got that error 40006..

Try connecting with only one winsock and see if that works. To find the cause, you need to start at the basics.

Remove anything that is not nessary. ie all winsock execpt one
Where abouts does it fail (what line), Is the syntax right, mispelt anything?

Create a new client server project and see if you can get one winsock to connect so you are able to send data to each client


You can send any text thru winsock. have a look here for sending multiple text thru http://www.daniweb.com/forums/thread107736.html

Try to assign values dynamically instead of all the hard coding .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.