Page 2 of 2 FirstFirst 12
Results 41 to 58 of 58

Thread: Client/Server Socket classes for file transfer

  1. #41

    Thread Starter
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Client/Server Socket classes for file transfer

    Thanks Milesh,

    I'm sure this will help many.

  2. #42
    New Member
    Join Date
    Feb 2009
    Posts
    3

    Re: Client/Server Socket classes for file transfer

    Elegant coding. I even can modified it into integrated chat apps.
    But can you tell me how can I retrieve sender ip address when
    a request coming in the server side.

    "Case Requests.PictureFile
    Sender.SendFile(msgTag, picDir & message)"

    I've debugging almost every parts of the code, but still can find the
    "sender" ip.
    Can anyone help?
    Thx in advance

  3. #43
    New Member
    Join Date
    Feb 2009
    Posts
    2

    Re: Client/Server Socket classes for file transfer

    Re #42 the IP address and port can be obtained from the listener_ConnectionRequest event. The sender is objet type of System.Net.Sockets.TcpClient this means the IP address and Port can be retrieved using the following syntax:

    vb Code:
    1. Requestor.Client.RemoteEndPoint.ToString.Substring


    I use the following to remove the port from the value from the returned from the above statement.

    vb Code:
    1. ClientIP= Requestor.Client.RemoteEndPoint.ToString.Substring(0, Requestor.Client.RemoteEndPoint.ToString.IndexOf(":"))

    It would appear that the server would have to forward the sender's IP.
    Last edited by milesh2160; Feb 28th, 2009 at 11:32 AM.

  4. #44
    New Member
    Join Date
    Feb 2009
    Posts
    3

    Re: Client/Server Socket classes for file transfer

    Thanks for the quick response, Milesh.
    I've already got it if it comes in the "listener_ConnectionRequest" event.
    But if you had several clients connecting in the same time, how would you know which client(s) requesting data or image?
    (back to the "listener_StringReceived" event)

    I'm still working on it right now and testing any possibilities.
    I should back to you later.

  5. #45
    New Member
    Join Date
    Feb 2009
    Posts
    3

    Re: Client/Server Socket classes for file transfer

    Resolved!!

    Using the client port(s) and ip(s) retrieved from the "listener_ConnectionRequest" event and sent its values to a public array.
    And when the client disconnected, call the array with indexes from "client.tag" in the "listener_MessageReceived" event.

    Cheers

  6. #46
    New Member
    Join Date
    Jun 2009
    Posts
    9

    Re: Client/Server Socket classes for file transfer

    To Moeur

    Hi ....I M Trying to implement Remote Desktop Viewer for my academic project submission...
    and I have used ur code for that and thanks alot for that.


    But the thing i wanted to ask u that how can i send the images i captured and saved on one Pc to the viewer on other PC using ur code...

    i've tried sending files on request repeatedly but i've failed to co-ordinate the request and the response...
    i've modified code as below for requesting
    Code:
    Private Sub cmdGetPicture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
            Handles cmdGetPicture.Click
            'request a picture file from server
            For i As Integer = 0 To 30 Step 1
                client.Send(Requests.PictureFile, i & ".jpg")
                If i = 30 Then
                    i = 0
                End If
            Next
    
        End Sub
    and created the files at other side as below:

    Code:
     
    Private Sub frmServer_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            'start listening on our port as soon as the form loads
            listener = New clsListener(PORT_NUM, PACKET_SIZE)
            thrd1 = New Thread(AddressOf listener.createFile)
            thrd1.Start()
        End Sub

    ur immidiate help would be grateful sir....

  7. #47
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091

    Re: Client/Server Socket classes for file transfer

    Is there a way to make this multithreaded in that the server can handle processing more than one request at a time? For example, I'm using the included client app to get a very large file. As the file is being received by the client, the client is not yet locked up. But if I attempt to click the "GetImage" button, it locks up and waits until the large file is downloaded, and then proceeds. I'm not sure if this is a client or server issue.

    Visual Studio 2010

  8. #48
    New Member
    Join Date
    Mar 2010
    Posts
    2

    Unhappy Re: Client/Server Socket classes for file transfer


    I'm trying to put this code around. But what i get is an error. Object references is not set to an instance of object. Can anybody help me fixing the code?

    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)

    Private Const VK_SNAPSHOT As Short = &H2CS

    dim bmap as bitmap

    Public Sub testing()
    Call keybd_event(System.Windows.Forms.Keys.Snapshot, 0, 0, 0)
    Dim data As IDataObject

    data = Clipboard.GetDataObject()

    If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
    bmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Bitmap)
    End If
    Catch e As Exception
    MsgBox(e.ToString())
    End Try
    End Sub

    Private Sub listener_StringReceived(ByVal Sender As tcpConnection, ByVal msgTag As Byte, ByVal message As String) Handles listener.StringReceived
    'This is where the client will send us requests for file data using our
    ' predefined message tags
    Debug.Print("String Received from Client: " & message)
    Select Case msgTag
    Case Requests.PictureFile
    testing()
    sender.SendImage(msgTag, bmap)
    End Select
    End Sub

    Please help me fix the code. Thanks in advance

  9. #49
    New Member
    Join Date
    Jun 2011
    Posts
    1

    Re: Client/Server Socket classes for file transfer

    Hello, i just wanted to ask is it possible to be able to transfer a file from client to server, not just from server to client as it is now?

    e.g i have a button now on client form that when i press it gets a file from the server. i also want to have a button that when i press will send a file from the client side to the server.

    Thank you in advance,
    Tom

  10. #50
    Member
    Join Date
    Feb 2010
    Posts
    63

    Re: Client/Server Socket classes for file transfer

    How to kick all connection on the server? not closing the application and restart the connection?

  11. #51
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Client/Server Socket classes for file transfer

    It doesn't appear that he has provided a means to do that through his class. In such a case you must access the underlying Socket object which has a Disconnect method.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  12. #52
    New Member
    Join Date
    May 2014
    Posts
    12

    Re: Client/Server Socket classes for file transfer

    Hi there

    Simple question... the origional thread was from 2004 - now we are in 2014 and talking vb in Visual Studio 2013.

    Is there any of your bright heads that could help in refreshing this to work in VS.net 2013, please?

    I'm to new to do this... have tried but in the client part are several parts not handled corretly be the normal upgrade function in VS.net...

    Thx.

    Best Regards
    /Mogens

  13. #53
    Member
    Join Date
    Feb 2010
    Posts
    63

    Re: Client/Server Socket classes for file transfer

    How to send file client to server?
    i saw a code but IDK how to declared for client.SendFile(IDK what to do here., "D:\Ads").

  14. #54
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Client/Server Socket classes for file transfer

    Boo!!
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Page 2 of 2 FirstFirst 12

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