Results 1 to 17 of 17
Thread: Sockets
- 05-21-2008, 03:17 PM #1
- 05-22-2008, 04:46 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I'm not clear what you expecting as an easier way. We can do in regular way we do,
normally I do it in this way.
Java Code:Socket TestClient; try { TestClient = new Socket("Machine name", PortNumber); } catch (IOException e) { System.out.println(e); }
- 05-22-2008, 05:30 AM #3
the problem is that the other user than has to have a server socket waiting for a connection. Is there an easy way to have a socket that listens for someone to connect to it then make it a normal socket then create another socket that waits for another connection or is there an easier way altogether.
My IP address is 127.0.0.1
- 05-22-2008, 05:46 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
That means you want to open multiple sockets on one side. I think the easiest way to do this is through a thread. Rapidly checking on available connections, we can open existing one. I don't know there is another easy way to do this.
- 05-22-2008, 01:37 PM #5
Can I have one socket dedicated to listening for connections to new people then when it finds someone have it make another socket equal to it then have the listening socket waiting for another new connection.
My IP address is 127.0.0.1
- 05-23-2008, 03:30 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I don't think so. When a socket is communicating, how can it release without destroying the connection.
But I think if you can distribute the time intervals in communicating thread, you can use the socket as another listener. But it's not easy, the numbers of events can handle at a time can be few.
- 05-23-2008, 01:50 PM #7
Use a server socket. It does exactly what you want. This is how servers work. they listen for connection requests on one port and then create a connection on another port for the client and continue to listen on the original port.
Daniel @ [www.littletutorials.com]
Language is froth on the surface of thought
- 05-23-2008, 03:00 PM #8
I understand that much about server sockets, but what I want is a client to be able to add new connections from his computer and simultaneously be able to have connections connect to him. Is there a way to do this I'm very new to networking actually I'm just doing this as a way to learn how to use sockets. I have used server sockets and regular sockets before, but all it did was send over a string.
My IP address is 127.0.0.1
- 05-23-2008, 09:45 PM #9
What if I made a "Socket" class that had two constructors. The class would have a Socket and a ServerSocket in it. Depending on which constructor I called it would set up the correct one. That way I could have a vector of "Sockets" that in the end where all the same thing. The last Socket in the Vector would be the socket listening in for a new connection. Would this work like I would like or what are your thoughts.
My IP address is 127.0.0.1
- 05-23-2008, 11:44 PM #10
Hi Zosden,
Before you do anything you have to have clear in mind what the end result is? What do you want to create? A peer to peer chat program? Each client is also a server? My question is how do you know how to find the clients? Usually every peer to peer network is based on some well known servers. The information has to be centralized somewhere. Look at the IRC protocol if you want to know more about chat applications. Everything else is just a refined copy.Daniel @ [www.littletutorials.com]
Language is froth on the surface of thought
- 05-24-2008, 01:50 AM #11
This program is just for learning purposes. I just wanted to learn how to use sockets.
My IP address is 127.0.0.1
- 05-26-2008, 04:25 PM #12
Is there away to do networking without working on the socket level.
My IP address is 127.0.0.1
- 05-27-2008, 03:27 AM #13
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
How did you communicate without a socket. I don't think there is another way.
- 05-27-2008, 03:58 AM #14
I was just wondering if it was possible
My IP address is 127.0.0.1
- 05-27-2008, 04:28 AM #15
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
If I found something I'll let you know.
- 05-27-2008, 02:20 PM #16
In Java at higher level you can use RMI.
Daniel @ [www.littletutorials.com]
Language is froth on the surface of thought
- 05-27-2008, 04:55 PM #17
@ daniel
I don't think that will help me with what I wont to do. I think that if I make a class that has a Socket and a ServerSocket in it then after they have connected to something they can both be used the same way. When I have time I will try it. If I works and I finish I will post my code so everyone can see it.My IP address is 127.0.0.1
Similar Threads
-
Sending files over sockets!
By rameshraj in forum NetworkingReplies: 2Last Post: 05-30-2008, 10:18 PM -
An echo server using UDP sockets
By Java Tip in forum java.netReplies: 0Last Post: 04-07-2008, 08:09 PM -
Sending Mail Using Sockets
By Java Tip in forum java.netReplies: 0Last Post: 04-07-2008, 08:05 PM -
how to send files through sockets
By gabriel in forum Advanced JavaReplies: 3Last Post: 01-12-2008, 08:10 AM -
Help with Sockets
By Eric in forum NetworkingReplies: 3Last Post: 12-01-2007, 08:09 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks