Accueil > > > CONSOLE WINSOCK(SERVEUR) AVEC COMMANDES SIMPLES V.1.0
CONSOLE WINSOCK(SERVEUR) AVEC COMMANDES SIMPLES V.1.0
Information sur la source
Description
Ce code n'est qu'une petite console permettant de changer les paramètres de base d'un serveur winsock.
Pour l'instant, il y a très peut de commandes disponibles mais assez pour démarrer un serveur fonctionnel. Toute fois, il n'y a pas réèlement d'utilitées.
Pour obtenir la liste des commandes tappez : HELP dans la ligne de commande.
Source
Option Explicit
Dim intTemp As Integer
Dim intFullCommandLen As Integer
Dim intCommandLen As Integer
Dim intComIndex As Integer
Dim requestID As Long
Dim requestID2 As Long
Dim strCommand As String
Dim strValue As String
Dim strEcho As String
Dim strComIndex(0 To 10) As String
Dim strData As String
Dim FlagComFound As Boolean
Private Sub Form_Load()
txtLog.Text = ""
txtComLog.Text = ""
txtCommand.Text = ""
End Sub
Private Sub Form_Resize()
On Error Resume Next
txtLog.Top = 120
txtLog.Left = 25
txtLog.Width = frmMain.Width - 200
txtLog.Height = (frmMain.Height / 2) - 400
txtComLog.Top = txtLog.Height + 200
txtComLog.Left = 25
txtComLog.Width = frmMain.Width - 200
txtComLog.Height = txtLog.Height - 400
txtCommand.Top = txtComLog.Top + txtComLog.Height + 200
txtCommand.Left = 25
txtCommand.Width = frmMain.Width - 200
End Sub
Private Sub txtCommand_KeyPress(KeyAscii As Integer)
'If KeyAscii = vbKeyUp Then
' intComIndex = intComIndex + 1
' txtCommand.Text = strComIndex(intComIndex)
'End If
'If KeyAscii = vbKeyDown Then
' intComIndex = intComIndex - 1
' txtCommand.Text = strComIndex(intComIndex)
'End If
If KeyAscii = vbKeyReturn Then
'Inutile pour le moment.... perte de temps... LOL
'strComIndex(10) = strComIndex(9)
'strComIndex(9) = strComIndex(8)
'strComIndex(8) = strComIndex(7)
'strComIndex(7) = strComIndex(6)
'strComIndex(6) = strComIndex(5)
'strComIndex(5) = strComIndex(4)
'strComIndex(4) = strComIndex(3)
'strComIndex(3) = strComIndex(2)
'strComIndex(2) = strComIndex(1)
'strComIndex(1) = strComIndex(0)
'strComIndex(0) = txtCommand.Text
strCommand = ""
strValue = ""
strEcho = ""
FlagComFound = False
txtCommand.Text = txtCommand.Text & " "
'Identifie la commande
For intTemp = 1 To Len(txtCommand.Text)
If Mid(txtCommand.Text, intTemp, 1) <> " " Then
strCommand = strCommand & Mid(txtCommand.Text, intTemp, 1)
Else
FlagComFound = True
intFullCommandLen = Len(txtCommand.Text)
intCommandLen = Len(strCommand)
'La commande est trouvée
'On identifie la valeur donné à la variable
strValue = Mid(txtCommand.Text, intTemp + 1, intFullCommandLen - intCommandLen + 1)
Select Case UCase(strCommand)
'>==================================================<
'>==================================================<
'>=LISTING COMPLET DES COMMANDES ET DE LEURS EFFETS=<
'>==================================================<
'>==================================================<
'----------------------------------------------------
'PARAMÈTRE DU PORT D'ÉCOUTE DU SERVEUR
'----------------------------------------------------
Case "SV_LISTENPORT"
If strValue <> "" Then
wskServer.LocalPort = strValue
strEcho = UCase(strCommand) & " Successfully set on " & UCase(strValue)
Else
strEcho = UCase(strCommand) & " = " & wskServer.LocalPort
End If
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'----------------------------------------------------
'VALEUR DE L'IP DU SERVEUR
'----------------------------------------------------
Case "SV_LISTENIP"
If strValue <> "" Then
'wskServer.LocalPort = strValue
'strEcho = UCase(strCommand) & " Successfully set on " & UCase(strValue)
strEcho = "This value (SV_LISTENIP) cannot be changed"
Else
strEcho = UCase(strCommand) & " = " & wskServer.LocalIP
End If
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'----------------------------------------------------
'OVERTURE/FERMETURE DU SERVEUR
'----------------------------------------------------
Case "SV_LISTEN"
If Trim(strValue) <> "" Then
If Trim(strValue) = "1" Then
wskServer.Listen
strEcho = "Server listening"
End If
If Trim(strValue) = "0" Then
wskServer.Close
strEcho = "Server Closed"
End If
'strEcho = UCase(strCommand) & " Successfully set on " & UCase(strValue)
'strEcho = "This value (SV_LISTENIP) cannot be changed"
Else
strEcho = UCase(strCommand) & " = " & wskServer.LocalIP
End If
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'----------------------------------------------------
'PARAMÈTRE DU PROTOCOLE SERVEUR
'----------------------------------------------------
Case "SV_PROTOCOL"
If UCase(Trim(strValue)) <> "" Then
If UCase(Trim(strValue)) = "TCP" Then
wskServer.Protocol = sckTCPProtocol
strEcho = "Server Protocol set on : TCP/IP"
End If
If UCase(Trim(strValue)) = "UDP" Then
wskServer.Protocol = sckUDPProtocol
strEcho = "Server Protocol set on : UDP"
End If
'strEcho = UCase(strCommand) & " Successfully set on " & UCase(strValue)
'strEcho = "This value (SV_LISTENIP) cannot be changed"
Else
strEcho = UCase(strCommand) & " = " & wskServer.LocalIP
End If
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'----------------------------------------------------
'COMMANDE HELP QUI RETOURNE LA LISTE DES COMMANDES
'----------------------------------------------------
Case "HELP"
txtComLog.Text = txtComLog.Text & "----------------------------------------------------------" & vbNewLine
txtComLog.Text = txtComLog.Text & "HELP FUNCTION : COMMAND LISTING " & vbNewLine
txtComLog.Text = txtComLog.Text & "----------------------------------------------------------" & vbNewLine
txtComLog.Text = txtComLog.Text & "1) SERVER SIDE " & vbNewLine
txtComLog.Text = txtComLog.Text & ".........................................................." & vbNewLine
txtComLog.Text = txtComLog.Text & "SV_LISTENPORT[Port] : Server listening Port " & vbNewLine
txtComLog.Text = txtComLog.Text & "SV_LISTENIP : Returns server IP " & vbNewLine
txtComLog.Text = txtComLog.Text & "SV_PROTOCOL[TCP-UDP] : Select server protocol (TCP or UDP)" & vbNewLine
txtComLog.Text = txtComLog.Text & "SV_LISTEN[1-0] : Open/Close server connection " & vbNewLine
txtComLog.Text = txtComLog.Text & ".........................................................." & vbNewLine
txtComLog.Text = txtComLog.Text & "2) OTHER FUNCTIONS " & vbNewLine
txtComLog.Text = txtComLog.Text & ".........................................................." & vbNewLine
txtComLog.Text = txtComLog.Text & "HELP : Returns the full listing of commands " & vbNewLine
txtComLog.Text = txtComLog.Text & ".........................................................." & vbNewLine
txtComLog.Text = txtComLog.Text & "----------------------------------------------------------" & vbNewLine
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'>==================================================<
'>==================================================<
'>==================== F I N =======================<
'>==================================================<
'>==================================================<
End Select
If strEcho <> "" Then
txtComLog.Text = txtComLog.Text & _
"<" & Day(Date) & "/" & Month(Date) & "/" & Year(Date) & "[" & Time _
& "]> " & strEcho & vbNewLine
GoTo CheckOut
End If
End If
Next intTemp
CheckOut:
txtCommand.Text = ""
End If
End Sub
Private Sub wskServer_ConnectionRequest(ByVal requestID As Long)
If wskServer.State <> 0 Then
wskServer.Close
wskServer.Accept requestID
requestID2 = requestID
strEcho = "Connection [" & requestID & "] Accepted"
txtLog.Text = txtLog.Text & _
"<" & Day(Date) & "/" & Month(Date) & "/" & Year(Date) & "[" & Time _
& "]> " & strEcho & vbNewLine
End If
End Sub
Private Sub wskServer_DataArrival(ByVal bytesTotal As Long)
wskServer.GetData strData
strEcho = "Data Received from ID[" & requestID2 & "] " & strData
txtLog.Text = txtLog.Text & _
"<" & Day(Date) & "/" & Month(Date) & "/" & Year(Date) & "[" & Time _
& "]> " & strEcho & vbNewLine
End Sub
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
DéMARRONS AVEC LES TASKSDéMARRONS AVEC LES TASKS par richardc
Que vous le vouliez ou non, le développement multi-tâche est maintenant une obligation pour toute nouvelle application. Il est donc vital d'en comprendre les mécanismes et de s'y mettre le plus tôt possible.
En attendant le .NET Framework 4.5 avec le...
Cliquez pour lire la suite de l'article par richardc SLIDE & DéMO TECHDAYS 2012 - FAST & FURIOUS XAML APPSSLIDE & DéMO TECHDAYS 2012 - FAST & FURIOUS XAML APPS par Vko
Retrouvez les slides et les démo de ma session Fast & Furious XAML Apps. A ceux qui se posent la question : "est-ce que le code de la DataGrid est disponible?", je vous répondrais "pas encore". Je vais mettre en place un projet codeplex pour part...
Cliquez pour lire la suite de l'article par Vko XNA IS DEAD!XNA IS DEAD! par richardc
Depuis la semaine dernière (et grâce aux TechDays 2012), je me penche activement sur la nouvelle version de Windows, aka Windows 8. Vous me direz, il était temps puisque la première preview date de Septembre dernier.
OK. Remarquez, on n'en est qu'aux...
Cliquez pour lire la suite de l'article par richardc TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 !TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 ! par ROMELARD Fabrice
Speakers: Fabrice Meillon et Stanislas Quastana Cette session est basée entièrement sur celle donnée lors de la BUILD cet hiver. Il n'y a pas d'ajout d'information en rapport avec cet évènement passé. Windows 8 Server sera intégralem...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [HTML5] AUTOUR DU W3C : NOUVEAUX STANDARDS ET WEB MOBILE (LILLE)[HTML5] AUTOUR DU W3C : NOUVEAUX STANDARDS ET WEB MOBILE (LILLE) par Gio
Je m'y prends un peu tard je sais, mais bon je suis développeur web et donc hyper fainéant ! Toujours dans le cadre des technologies émergentes, ici HTML5, parce qu'on aime HTML5 chez Wyg , nous seront présent, le vieux ( Aurélien V.) et moi, pour pr...
Cliquez pour lire la suite de l'article par Gio
Logiciels
DocTranslate (V3.1.0.0)DOCTRANSLATE (V3.1.0.0)DocTranslate est un traducteur de document Microsoft Word, PowerPoint et Excel. Il permet d'autom... Cliquez pour télécharger DocTranslate Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System
|