Merhaba, herhangi bir anlatımımız yok ancak bir form uzerine 2 adet winsock 1 adet commandbutton bir de textbox eklerseniz bu kodu rahatlıkla calıştırırsınız. Eğer isterseniz zipi indirebilirsiniz : winsockfornext.zip

Option Explicit

Dim gitti As Boolean

Dim link As Boolean



Dim timeout As Date



Dim i As Byte



Sub Yolla_Bakam()



For i = 1 To 10



gitti = False

link = False

timeout = Now



YOLLA.Connect



Do

DoEvents

If DateDiff("s", timeout, Now) > 5 Then

MsgBox "5sn icinde karşıya bağlantı sağlanamadı.", vbCritical

GoTo soket_kapat

End If

Loop Until link



YOLLA.Senddata i & " - vbturk.net - " & i

timeout = Now



Do

DoEvents



If DateDiff("s", timeout, Now) > 5 Then

YOLLA.Close

YOLLA.Connect

MsgBox "5sn icinde veri karşıya gonderilemedi.", vbCritical

Exit Do

End If



Loop Until gitti



soket_kapat:

YOLLA.Close



Next



i = 0



End Sub



Private Sub Command1_Click()

Yolla_Bakam

End Sub



Private Sub dinle_Close()

'If dinle.State = sckClosing Then

dinle.Close

dinle.Listen

'End If

End Sub



Private Sub dinle_ConnectionRequest(ByVal requestID As Long)

If dinle.State sckClosed Then dinle.Close

dinle.Accept requestID

End Sub



Private Sub dinle_DataArrival(ByVal bytesTotal As Long)

Dim gelen As String

dinle.GetData gelen, vbString

Text1.Text = gelen & vbCrLf & Text1.Text

End Sub



Private Sub Form_Load()

dinle.LocalPort = 231

dinle.Listen

End Sub



Private Sub yolla_Close()

YOLLA.Close

End Sub



Private Sub yolla_Connect()

link = True

End Sub



Private Sub yolla_SendComplete()

gitti = True

End Sub
__________________