|
-
Feb 17th, 2009, 06:24 PM
#41
Re: Client/Server Socket classes for file transfer
Thanks Milesh,
I'm sure this will help many.
-
Feb 28th, 2009, 09:51 AM
#42
New Member
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
-
Feb 28th, 2009, 11:24 AM
#43
New Member
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:
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:
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.
-
Feb 28th, 2009, 12:23 PM
#44
New Member
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.
-
Feb 28th, 2009, 04:33 PM
#45
New Member
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
-
Aug 11th, 2009, 08:29 AM
#46
New Member
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....
-
Feb 24th, 2010, 04:59 PM
#47
Frenzied Member
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.
-
Mar 23rd, 2010, 08:54 AM
#48
New Member
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
-
Jun 25th, 2011, 03:56 PM
#49
New Member
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
-
Apr 28th, 2014, 10:53 PM
#50
Member
Re: Client/Server Socket classes for file transfer
How to kick all connection on the server? not closing the application and restart the connection?
-
Apr 30th, 2014, 02:15 AM
#51
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.
-
May 14th, 2014, 07:16 AM
#52
New Member
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
-
May 19th, 2014, 04:07 AM
#53
Member
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").
-
Jun 6th, 2014, 02:39 PM
#54
Re: Client/Server Socket classes for file transfer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|