Results 1 to 40 of 66

Thread: Socket Issue[Resolved]

Hybrid View

  1. #1
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Socket Issue

    Regarding to the post you edited

    sockaddr.sin_addr = 66
    sockaddr.sin_addr = 66 ' this just overides the previous 66, therefore you end up with 66 in the end, not "66.66.66.66"...


    I did not test it, but I think this is the API that converts from string address to a Long
    VB Code:
    1. Public Declare Function inet_addr Lib "ws2_32.dll" (ByVal cp As String) As Long
    EDIT, Here's the MSDN help for it MSDN - inet_addr

    You have to use it like:
    VB Code:
    1. Dim server As sockaddr
    2. server.sin_addr = inet_addr("66.66.66.66")
    3.  
    4. If (Connect(MySocket, server, Len(server))) = SOCKET_ERROR Then
    5.  
    6. '... the rest of the code

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Posts
    279

    Re: Socket Issue

    Also, in regards to the comment you made about puting the winsock control on a form hidden in your dll. I just did that it works fine without errors but when I try calling it in a Module like:
    VB Code:
    1. Dim ip As String
    2. ip = Form1.Winsock1.LocalIP
    3. MsgBox ip
    It just exits the DLL. Closes it immediately without reason.

    So I take it it's not going to happen, eh?


    EDIT:
    VB Code:
    1. Dim server As sockaddr
    2. server.sin_addr = inet_addr("66.66.66.66")
    3.  
    4. If (Connect(MySocket, server, Len(server))) = SOCKET_ERROR Then
    Do you know how I can somehow put a port in there too for it to connect to also?
    Last edited by Tantrum3k; Aug 12th, 2005 at 04:08 PM.

  3. #3
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Socket Issue

    Quote Originally Posted by Tantrum3k
    VB Code:
    1. Dim ip As String
    2. ip = Form1.Winsock1.LocalIP
    3. MsgBox ip
    Try without displaying the ip in the message box... a DLL is not supposed to have an interface, than's why I told you to make the form.Visible = False

    Quote Originally Posted by Tantrum3k
    Do you know how I can somehow put a port in there too for it to connect to also?
    VB Code:
    1. Dim server As sockaddr
    2. server.sin_port = 80 ' or some other port...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width