Page 1 sur 1

socket

MessagePublié: 06 Nov 2007 à 09:12
par Michael DELIQUE
Code : Tout sélectionner
Public Function SocketsCleanup_API() As Integer
   
%REM
'variables API pour la fonction SocketsCleanup_API
Declare Function WSACleanup Lib "wsock32" () As Long
%END REM
   
   On Error Goto ErreurSocketsCleanup_API
   
   If WSACleanup() <> 0 Then
      SocketsCleanup_API= False
   Else
      SocketsCleanup_API = True
   End If
   
   Exit Function
ErreurSocketsCleanup_API:
   Msgbox "("+Cstr(Getthreadinfo (1))+" Call by "+Cstr(Getthreadinfo(10))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + Cstr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"
   Exit Function
End Function


Code : Tout sélectionner
Public Function SocketsInitialize_API() As Integer
   
%REM
'Variables API pour la fonction SocketsInitialize_API
Const IP_SUCCESS = 0
Const WSADescription_Len = 255 ' 256, 0-based
Const WSASYS_Status_Len = 127 ' 128, 0-based
Const WS_VERSION_REQD = &H101

Type WSADATA
   wVersion As Integer
   wHighVersion As Integer
   szDescription(0 To WSADescription_Len) As Integer
   szSystemStatus(0 To WSASYS_Status_Len) As Integer
   wMaxSockets As Long
   wMaxUDPDG As Long
   dwVendorInfo As Long
End Type

Declare Function WSAStartup Lib "wsock32" (Byval wVersionRequired As Long,lpWSADATA As WSADATA) As Long
%END REM
   
   'Déclaration Variables
   Dim WSAD As WSADATA
   Dim success As Long
   
   On Error Goto ErreurSocketsInitialize_API
   SocketsInitialize_API = (WSAStartup(WS_VERSION_REQD, WSAD) = IP_SUCCESS)
   
   Exit Function
ErreurSocketsInitialize_API:
   Msgbox "("+Cstr(Getthreadinfo (1))+" Call by "+Cstr(Getthreadinfo(10))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + Cstr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"

   SocketsInitialize_API = 0
   Exit Function
End Function