Código
Option Explicit Private Declare Function WSAStartup Lib "WSOCK32" (ByVal wVersionRequired As Long, lpWSADATA As WSAData) As Long Private Declare Function socket Lib "wsock32.dll" (ByVal af As Long, ByVal s_type As Long, ByVal protocol As Long) As Long Private Declare Function htons Lib "wsock32.dll" (ByVal hostshort As Long) As Integer Private Declare Function Bind Lib "wsock32.dll" Alias "bind" (ByVal s As Long, ByRef name As sockaddr, ByVal namelen As Long) As Long Private Const MAX_WSADescription = 256 Private Const MAX_WSASYSStatus = 128 Private Const WS_VERSION_REQD As Long = &H101 Private Const AF_INET As Long = 2 Private Const SOCK_STREAM As Long = 1 Private Const IPPROTO_TCP As Long = 6 Private Const INADDR_ANY As Long = &H0 Private Type sockaddr sin_family As Integer sin_port As Integer sin_addr As Long sin_zero As String * 8 End Type Private Type WSAData wVersion As Integer wHighVersion As Integer szDescription(0 To MAX_WSADescription) As Byte szSystemStatus(0 To MAX_WSASYSStatus) As Byte wMaxSockets As Integer wMaxUDPDG As Integer dwVendorInfo As Long End Type Public Function Dsocket() As Boolean Dim IniciarSocket As Integer Dim WSAS As WSAData Dim sock As Integer Dim sa As sockaddr IniciarSocket = WSAStartup(WS_VERSION_REQD, WSAS) sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) sa.sin_family = AF_INET sa.sin_addr = INADDR_ANY sa.sin_port = htons(22233) If (Bind(sock, sa, LenB(sa)) = -1) Then MsgBox "error": Exit Function End If Exit Function error: Exit Function End Function Private Sub form_load() Dsocket End Sub
salu2! y esperando respuesta.