Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  UDP Two Sockets, One port, Local  (Read 2294 times)
0 Members and 1 Guest are viewing this topic.
Offline counterp

Senior Member


Medals: 11



« Posted 2011-09-28 01:57:31 »

Is it possible for a packet to be sent to a specific socket that is listening on the same port as another socket in a different application, in UDP.

At the moment, it only picks one of the sockets to always send the packets to (the first socket listening). the second socket doesn't receive anything.

Visualization:

I have a SERVER, and two sockets, SOCKET1 and SOCKET2.

SOCKET1 listening on 127.0.0.1:1837
SOCKET2 listening on 127.0.0.1:1837

SERVER sending packet to 127.0.0.1:1837

SOCKET1 will always receive the packets, can i specify for SOCKET2 to receive certain packets, and SOCKET1 certain others?
Offline ra4king

JGO Kernel


Medals: 337
Projects: 2
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2011-09-28 04:49:50 »

Nope.

Offline theagentd
« Reply #2 - Posted 2011-09-28 12:31:18 »

Just sort them yourself? If YOU can't do that, how do you expect the OS to do it for you? xd

Myomyomyo.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline counterp

Senior Member


Medals: 11



« Reply #3 - Posted 2011-09-28 15:59:47 »

like I said, only first socket receives the packets.

darn ittt there must be a work around?
Offline SimonH
« Reply #4 - Posted 2011-09-28 16:49:56 »

I've been trying to work out why you need to do this...?
Why not just use another port for socket2 or filter the packets from socket1?

People make games and games make people
Offline sproingie

JGO Kernel


Medals: 202



« Reply #5 - Posted 2011-09-28 17:35:47 »

You should have gotten an exception when you attempted to bind two sockets to the same port.  The only way you can bind two sockets to the same port is with multicast, and I suspect that's not actually what you're after.

Offline counterp

Senior Member


Medals: 11



« Reply #6 - Posted 2011-09-29 04:24:47 »

it is multicast (as intended), problem is both sockets don't receive the packets, only one does.

EDIT: fixeddddd
Offline sproingie

JGO Kernel


Medals: 202



« Reply #7 - Posted 2011-09-29 06:12:18 »

127.0.0.1 is not a multicast address, and you are not using a multicast API.  Just saying it's multicast does not make it multicast.  I'd link to the proper API for multicast sockets, but I really don't want to confuse the issue further than I already have.

Offline counterp

Senior Member


Medals: 11



« Reply #8 - Posted 2011-09-29 07:51:54 »

I'm aware... doesn't change the fact that the sockets are listening on 127.0.0.1

Offline ra4king

JGO Kernel


Medals: 337
Projects: 2
Exp: 5 years


I'm the King!


« Reply #9 - Posted 2011-09-29 13:24:51 »

counterp, how did you fix it?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline counterp

Senior Member


Medals: 11



« Reply #10 - Posted 2011-09-30 05:14:18 »

I was trying to send a UDP packet to a SocketAddress instead of a group (I was using multicast sockets), but when I do this, it only sends it to the first socket registered (instead of all sockets listening on that specific address and port). I could send a UDP packet to the whole group, and everyone, including the two sockets listening on the same address and port would receive it.

I didn't want that though because the information sent had to do with sending a unique ID to a specific client that I wanted to remain private.

I just used TCP in the end since it's a one time thing (sends ID on login), and I also needed reliability for this. (should have done this from beginning)
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (13 views)
2014-07-29 18:09:19

Riven (10 views)
2014-07-29 18:08:52

Dwinin (10 views)
2014-07-29 10:59:34

E.R. Fleming (26 views)
2014-07-29 03:07:13

E.R. Fleming (10 views)
2014-07-29 03:06:25

pw (40 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (27 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!