 |
|
 |
I was wondering if you could help with a problem. I am trying to create a tcpclient in an asp.net page (vb) and have it stay connected and send messages to a tcp listener device. This device sends a sessionID to every connection, which must be incorporated in to all ensuing messages that control the device. All examples of the tcpclient have two limitations for a newbie like me. First,they are written for winforms apps, and second they only connect, send the message then disconnect. The tcpclient appears to have to be instantiated every time a message is sent. This will not work for me as the sessionID will have changed. Any suggestions, code samples or sites you can point me to?
Thanks in advance, Nimesh.
|
|
|
|
 |
|
 |
Sirs,
I like to go with your suggestion. Could you help me with code how to send a text stream from one application to the other.
Thanking You.
Hariram
|
|
|
|
 |
|
 |
I'm sorry, but If this is for your homework...I think I have helped you as much as I can...I dont mind 'Helping' but I wont do it for you...you wont learn anything like that
Pablo
Sometimes I think there's no reason to get out of bed . . . then I feel wet, and I realize there is.
|
|
|
|
 |
|
 |
Dear Sirs,
Could you help how me to resolve my problem in remoting in VB.NET
I like to inform you that I’m in between beginner and moderate level. I’m developing a application in VB.NET using remoting concept for my academic purpose. I need replica of a object which is created in a server application to be accessed in other remote client machine…
Kindly help me as I’m nearing my dealine…
I’ll explain you briefly through a sample code…
First I’ll run this application and initialize the object…
Application 1(server):
Class file :
Class x
Public y as integer
…
…
End class
VB file:
Function init()
Dim ab as x
Ab.y=5
End function
After running the application 1, then I’m running the client machine.
Application 2(Remote Client):
VB file:
Dim obj as remoteobj
dim x as integer
x=obj.y
so that the value gets stored in the variable x.
Hariram
|
|
|
|
 |
|
 |
If the object is only editable on the server side...you could set up a chain something like this:
assume object name is 'x'
server->edit x
server->pass x to client1
client1->read x and do what it is suposed to
client1->(this stage is up to you...pass it or report a finish) Inform
server that we have received the data, or we could pass it to the
next client...there are up's and downs to this, a down would be that
a client that crashes could break the chain...probably best to have
the server send out packets to clients and wait to see if they get
them before sending them the next packet.
client2->if you choose to have the clients pass data to the next client...
it is now client2's turn to interact with the data...last client
will pass the data back to the server letting it know that the data
went all the way around the loop.
Depending on your setup...and if there are references to other objects created on the server in your packet; this could work. There are tones of ways to do this, but most of them depend on your setup, language, datatype, etc...
A posibly easyer solution could be to have your clients request the data from the server in a comma delimited string that the client could convert into an object once it was recieved...it really all depends on what you are trying to do.
Hope this was helpfull, let me know if I can help in any other way.
Pablo
Sometimes I think there's no reason to get out of bed . . . then I feel wet, and I realize there is.
|
|
|
|
 |
|
 |
Sirs,
Thank you for your reply...
i'll explain my problem more simply...
i'm creating an object in server. and i have to access the same object in the client. and also i've edit the object in the client.
could you help me with sample code.
Hariram
|
|
|
|
 |
|
 |
I'm sorry, I am getting ready to go to work so I dont have time to put together a sample at this time. However here is a sugestion:
First you will have to avoid the issue of two clients editing data at the same time, because you will lose data that way...
Second I would use strings to instantiate the objects and make the design something like this:
client->request string from server
client->translate string into object
client->edit object
client->translate object into string
client->return string to server
server->translate string into object
server->process object
server->wait for next request
If there is sensitive material in the string...encrypt it before sending it back and forth.
Public Class StrHandler
Public Sub New(theStr as String)
dim vars() as String = theStr.Split(",")
m_Var1 = vars(0)
m_Var2 = vars(1)
m_Var2 = vars(2)
etc...
etc...
End Sub
Public Overrides Function ToString() As String
Return m_Var1 & "," & m_Var2 & "," & m_Var3 etc, etc
End Function
End Class
Pablo
Sometimes I think there's no reason to get out of bed . . . then I feel wet, and I realize there is.
|
|
|
|
 |
|
 |
Hi,
There's an alternative way to retrieve the IP address of a TcpClient, and that's using the Client property of the TcpClient to access the remote end-point. The remote endpoint provides an IP address and a port, if you cast it to an IPEndPoint.
-- Tom Spink, Über Geek.
|
|
|
|
 |
|
 |
Cool, thanks for the info. I will have to try it out
Pablo
Sometimes I think there's no reason to get out of bed . . . then I feel wet, and I realize there is.
|
|
|
|
 |
|
 |
sir,
i am not getting so please can u brief it out..
thanks in advance
manju
|
|
|
|
 |
|
 |
Hi,
/// C#
TcpClient cli;
IPEndPoint ep = (IPEndPoint)cli.Client.RemoteEndPoint;
///
The 'ep' variable now contains the remote endpoint of the TCP client, from which you can derive the IP address by using the 'Address' property, and the port from the 'Port' property:
///
IPAddress addr = ep.Address;
int port = ep.Port;
///
Hope this helps.
-- Tom Spink, Über Geek.
|
|
|
|
 |