elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Guía rápida para descarga de herramientas gratuitas de seguridad y desinfección


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Un problemilla con Winsock
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Un problemilla con Winsock  (Leído 1,080 veces)
Homongus

Desconectado Desconectado

Mensajes: 77



Ver Perfil
Un problemilla con Winsock
« en: 19 Agosto 2007, 05:40 am »

Tras leer un poco de Python, decidí que lo mejor era pulir mis capacidades con VB antes de saltar a otro lenguaje.
Pues bien, me tope con la desagradable sorpresa de que la copia (ilegal) que consegui no contenía los controles active X de Winsock.
Ahora, mi duda es ¿debería conseguir una copia mejor o existe algún sitio donde descargar los controles (aptos para el desarrollo, claro)?
Gracias.


En línea

HaDeS, -
WarZone Master

Desconectado Desconectado

Mensajes: 284



Ver Perfil WWW
Re: Un problemilla con Winsock
« Respuesta #1 en: 19 Agosto 2007, 05:47 am »

Entra a http://www.ascentive.com/support/new/support_dll.phtml?dllname=MSWINSCK.OCX y descarga el fichero que te indican, ahi mismo te dicen como activar el componente y a donde lo debes copiar.
saludos y espero que te sirva!


En línea

APOKLIPTICO


Desconectado Desconectado

Mensajes: 3.871


Toys in the attic.


Ver Perfil
Re: Un problemilla con Winsock
« Respuesta #2 en: 19 Agosto 2007, 14:02 pm »

Tambien podes usar la Api de Winsock directamente, que no necesita el OCX...
Aqui Va...

Código
  1. Declare Function Socket Lib "wsock32.dll" Alias "socket" (ByVal afinet As Integer, ByVal socktype As Integer)
  2.  
  3. Declare Function connect Lib "wsock32" (ByVal sock As Long, name As SOCK_ADDR, ByVal namelen As Integer) As Long
  4.  
  5. Declare Function bind Lib "wsock32" (ByVal sock As Long, addr As SOCK_ADDR, ByVal namelen As Long) As Long
  6.  
  7. Declare Function listen Lib "wsock32.dll" (ByVal sock As Long, ByVal backlog As Integer) As Integer
  8.  
  9. Declare Function send Lib "wsock32" (ByVal sock As Long, buffer As Any, ByVal length As Long, ByVal flags As Long) As Long
  10.  
  11. Declare Function recv Lib "wsock32" (ByVal sock As Long, buffer As Any, ByVal length As Long, ByVal flags As Long) As Long
  12.  
  13. Type IN_ADDR
  14.    S_addr As Long
  15. End Type
  16.  
  17. Type SOCK_ADDR
  18.    sin_family As Integer
  19.    sin_port As Integer
  20.    sin_addr As IN_ADDR
  21.    sin_zero(0 To 7) As Byte
  22. End Type
  23.  
  24. Public Const PF_INET = 2
  25. Public Const SOCK_STREAM = 1
  26. Public Const SOCK_DGRAM = 2
  27. Public Const IPPROTO_IP = 0
  28. Public Const IPPROTO_TCP = 6
  29. Public Const IPPROTO_UDP = 17
  30. Public Const INVALID_SOCKET = -1
  31. Public Const SOCKET_ERROR = -1
  32. Public Const INADDR_ANY = &H0
  33. Public Const SOCKET_ERROR = -1
  34. Public Const MSG_OOB = &H1
  35. Public Const MSG_DONTROUTE = &H4
  36. Public Const MSG_OOB = &H1
  37. Public Const MSG_PEEK = &H2
  38.  
  39.  
  40. 'connect permet de se connecter sur un server distant
  41.  
  42. Dim CR As Long
  43. Dim sock As Long
  44. Dim RemoteServer As SOCK_ADDR
  45.  
  46. RemoteServer.sin_family = AF_INET
  47. RemoteServer.sin_port = htons(2000)
  48. RemoteServer.sin_addr.S_addr = inet_addr("XXX.XXX.XXX.XXX")
  49. RemoteServer.sin_zero(0) = 0
  50. CR = connect(sock, RemoteServer, Len(RemoteServer))
  51.  
  52.  
  53. 'Création d 'un socket
  54.  
  55. Dim sock As Long
  56. sock = Socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
  57.  
  58.  
  59. 'Port
  60.  
  61. Dim CR As Long
  62. Dim LocalServer As SOCK_ADDR
  63. LocalServer.sin_family = AF_INET
  64. LocalServer.sin_port = 0
  65. LocalServer.sin_addr.S_addr = INADDR_ANY
  66. CR = bind(sock, LocalServer, Len(LocalServer))
  67.  
  68.  
  69. 'listen permet de mettre un socket en attente de connection
  70.  
  71. Dim CR As Long
  72. Dim sock As Long
  73. CR = listen(sock, 1)
  74.  
  75. 'send permet d'envoyer
  76.  
  77. Dim CR As Long
  78. Dim longSend As Long
  79. longSend = Len(chaine)
  80. ReDim buff(longSend + 1) As Byte
  81. For i = 1 To longSend
  82.    buff(i - 1) = Asc(Mid(chaine, i, 1))
  83. Next
  84. buff(longSend) = 0
  85. CR = send(sock, buff(0), longSend, 0)
  86.  
  87.  
  88. 'recv permet de lire dans un socket
  89.  
  90. Const MAX_BUFF_SIZE = 10000
  91. Dim buff(0 To MAX_BUFF_SIZE) As Byte
  92. Dim sock As Long
  93. Dim CR As Long
  94.  
  95. CR = recv(sock, buff(0), MAX_BUFF_SIZE, 0)
  96.  
  97.  
  98. 'closesocket permet de fermer un socket
  99.  
  100. Dim Result As Long
  101. Dim sock As Long
  102.  
  103. Result = closesocket(sock)

Fuente: Site de programmation en Visual Basic

Espero que te sirva!!
Saludos
En línea

AMD Phenom II 1075T X6 @ 290 Mhz x 11 (HT 2036 Mhz NB Link 2616 Mhz) 1.23 Vcore
ASUS M4A89GTD-PRO/USB3
2x2gb G-Skill RipjawsX DDR3 1600 Mhz CL7 (7-8-7-24-25-1T)
Seagate 500 Gb
XFX HD4850 512Mb GDDR3. 650 Mhz/995 Mhz 1.1 Tflops.
Homongus

Desconectado Desconectado

Mensajes: 77



Ver Perfil
Re: Un problemilla con Winsock
« Respuesta #3 en: 20 Agosto 2007, 22:13 pm »

Muchas gracias a los dos. Un saludo
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines