ip haberlesmesinin fiziksel seviyede nasil yapildigi onemli degildir. Sonucta hepsi IP. onun icin sadece karsi tarafin IP adresine bir soket acmak ve port acilinca bilgiyi yollamak, obur taraftada soketi dinelyip gelen bilgiyi okuyacak bir program yazmak yeterli. Visual basic ile bunu yapacak programlari internetden bulabilirsin.
Ben kucuk/hizli programlarimi daha cok python ile yazdigim icin sana python programi ornek verebilirim, ama isine yararmi bilmem. Birde su siralar cok mesgulum, 15 gun icinde daha cok yardimci olabilirim.
kolay gelsin.
demistim ama uykum kacti biraz surf edince sana internetden ornek prg buldum. ama ingilizce
simdi iki bilgisayari konusturmak icin istemci-sunucu bir sistem kurmak lazim
ekte sana hem istemci hemde sunucu icin kullanman gereken programlari ekte yolluyorum.VB bilen birilerine bir soruver:
istemcinin IP adresinin ne oldugu program icin gerekli degil. istemci programinin sunucu bilgisayarin IP adresini ve sunucunun servis verdigi soket numarasini bilmesi gerek (asagidaki programda soket portu 50505 diye secilmis,)
SUNUCU
=========
Dim strData As String ' string for received data
Private Sub Form_Load()
sock.Protocol = sckTCPProtocol ' choose the TCP protocol
sock.LocalPort = 50505 ' an example port number
sock.Listen ' tell Winsock to start listening
End Sub
Private Sub sock_Close()
sock.Close ' has to be called
sock.Listen ' listen again
End Sub
Private Sub sock_ConnectionRequest(ByVal requestID As Long)
If sock.State = sckListening Then ' if the socket is listening
sock.Close ' reset its state to sckClosed
sock.Accept requestID ' accept the client
MsgBox "Connected with " & sock.RemoteHostIP
' show who we are connected with
End If
End Sub
Private Sub sock_DataArrival(ByVal bytesTotal As Long)
sock.GetData strData ' load received data into strData
txtOther.Text = strData ' show new string
End Sub
Private Sub sock_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "Socket Error " & Number & ": " & Description
' show some "debug" info
sock.Close ' close the erraneous connection
sock.Listen ' listen again
End Sub
Private Sub txtMe_Change()
If sock.State = sckConnected Then ' if there is a connection
sock.SendData txtMe.Text ' send data to the other side
End If
End Sub
========================================================================
ISTEMCI
=======
Dim strData As String ' string for received data
Private Sub cmdCon_Click()
If sock.State = sckClosed Then ' if the socket is closed
sock.RemoteHost = txtIP.Text ' set server adress
sock.RemotePort = txtPort.Text ' set server port
sock.Connect ' start connection attempt
Else ' if the socket is open
sock.Close ' close it
End If
End Sub
Private Sub sock_Close()
sock.Close ' has to be
called
End Sub
Private Sub sock_DataArrival(ByVal bytesTotal As Long)
sock.GetData strData ' load received data into strData
txtOther.Text = strData ' show new string
End Sub
Private Sub sock_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "Socket Error " & Number & ": " & Description
' show some "debug" info
sock.Close ' close the erraneous connection
End Sub
Private Sub txtMe_Change()
If sock.State = sckConnected Then ' if there is a connection
sock.SendData txtMe.Text ' send data to the other side
End If
End Sub