|
-
December 17th, 2010, 04:35 AM
#1
Help with TCP
Ok, I am developing an Application that uses TCP To listen for connections, and then when a message is sent to the server and then it alerts the IP that is running the server.
(Lets say the server is on a iPhone, and some how the iPhone gets a text message, which alerts a tcp server running in the background via a .jar, it would send the owner of the iPhone a message on the computer telling it it has a text. This is just an example though, but i think it gets the general idea across. And don't flame me because it sounds like an iPhone Rat, it's not. As i said, it's an example.)
I've been trying to do this, and i can connect to a TCP Server (using 127.0.0.1:8888 for testing purposes, will move to a solid IP and Port later)
I can start the server (its still buggy and under development) but i don't know how to connect to the server via an application, and when a certain message is received to alert the IP Running the server
My Server Code is:
Code:
Dim serverSocket As New TcpListener(8888)
Dim clientSocket As TcpClient
Dim infiniteCounter As Integer
Dim counter As Integer
serverSocket.Start()
msg("Chat Server Started ....")
counter = 0
infiniteCounter = 0
For infiniteCounter = 1 To 2
infiniteCounter = 1
counter += 1
clientSocket = serverSocket.AcceptTcpClient()
Dim bytesFrom(10024) As Byte
Dim dataFromClient As String
Dim networkStream As NetworkStream = _
clientSocket.GetStream()
networkStream.Read(bytesFrom, 0, CInt(clientSocket.ReceiveBufferSize))
dataFromClient = System.Text.Encoding.ASCII.GetString(bytesFrom)
dataFromClient = _
dataFromClient.Substring(0, dataFromClient.IndexOf("$"))
next
Now i know that to connect you'd do something like
Code:
Dim clientSocket As New System.Net.Sockets.TcpClient()
Dim serverStream As NetworkStream
clientSocket.Connect("127.0.0.1", 8888)
serverStream = clientSocket.GetStream()
and i know i would have to use some sort of Byte() method to send/receive messages, but i'm at a loss on how to set it all up 
Was wonderin' if anycone could help me?
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
|