Results 1 to 4 of 4

Thread: Sockets

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    55
    i want in to make a program, which accepts a command via sockets, and act upon each command differently, i.e: start recieving a file, store the next 10 strings in a record, etc.
    what should i write in Winsck_DataArrival ?
    and what next ? how do i make it know when to start recieving a file and when to start reciving the strings, and also other 'commands' ?

  2. #2
    Guest
    You should make a protocol for the information you send.

    For example you send

    MSGB, Then the receiving program knows it needs to display a messagebox.

    SRCF, Instruction for receiving a file etc.

    Example:
    Code:
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
        Dim sData As String
        Winsock1.GetData sData
        Select Case UCase$(sData)
            Case "MSGB"
                MsgBox "Program recieved command to display a messagebox"
            Case "SRCF"
                'Start file recieve function
            'End Case
        End Select
    End Sub
    As for sending files/strings, what I find useful is to open an additional winsock, and send the file to that one, and then close the winsock when the file is done. This is almost necessary for binary files because you can't send a char for termination(because that one might be used in the file).


    Hope it helps,

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    55

    gettting the file.

    but how do i recieve the file itself ?


    when i'll do winsock.getdata in another function, won't it run the winsock_dataaraival again ?


  4. #4
    Guest
    Add a second winsock, winsock2 for example, and use that to send the data to, then use the getdata method on winsock2

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