Ashish-24 wrote: > > On Wed, Apr 8, 2009 at 9:00 PM, Ponnapalli Hari Gopal > <[email protected]> wrote: >> >> Hi, >> I am bit new to the network programming. I am developing a server based >> on Mina using datagram sockets. I am bit confused with the datagram >> sockets here. When I start an instance of the server on a port (say 1812) >> it starts. However, when I run a second instance of the server on same >> port, it also binds to that port successfully. I am expecting that the >> bind should fail here as the port is already in use, the TCP/IP way. Is >> it an expected behavior of UDP datagrams? >> >> If this is the expected behavior, how do I know which instance of the >> server receives the packets? > > See this > http://www.softlab.ntua.gr/facilities/documentation/unix/unix-socket-faq/unix-socket-faq-2.html#time_wait > This is TCP stack behaviour. You may want to set reuseaddress to false > >>>I will check this. Is it a default beavior in DatagramAcceptor of Mina? Because, if I use SocketAcceptor and try to run a second instance on same port, same machine, it immediately fail with bind exception saying port already in use. In that scenario, I need not set this reuseaddress to false. > >> Basically, I am trying to develop a RADIUS server on top of Mina. The >> server is up and running. However, if there are multiple instances of the >> server running, sometimes I am facing strange behavior in terms of none >> of the servers are receiving the packets. > > All of them should run on different ports or on different machines, > else you have to develop a protocol above TCP for demultiplexing > >>> I think, my explanation was confusing. What all I want is a single >>> instance of the server running on a given machine on a given port. If >>> any attempt made to run a second instance on same machine, same port, it >>> should fail. However, with the code I shared, the second instance also >>> runs, without throwing exception. So, I want to correct that behavior. > >> Can someone provide any pointers on how to developa datagram server >> reliably. I also want to provide some start, shutdown scripts that allows >> the users to start, stop the server. For this, any guidance on what is >> the approach to be > > Can plan to use JMX or simple shell scripts will do. > > followed. If I start the server in a new thread, and close the main > program, the server thread also (being child) is getting closed. So, > do I need to start a separate port on which server listens for > administrative commands like start, shutdown? > > If your close the main program means exits the JVM, no Java program > can run. You should think of running the program as background process > >>> Yes, precisily. As the exit main is end of JVM, I could not leave the >>> server running. Will check how to run a java program as a background >>> process. > > In such case how to provide authentication of it? Or shall I need to > use some shared memory (flag) that will be used by both server and > startup/shutdown scripts. In such case the server requires constant > polling of the shared variable to start/stop the server. >> >> Also does the RADIUS need to be mandatarily supported only on UDP? > > RFC's are better place to look for this. > >> >> Sorry for my stupid questions, but, any ideas/guidance on same is highly >> appreciated. >> >> Regards, >> Hari >> >> >> >> > > > > -- > thanks > ashish > > Blog: http://www.ashishpaliwal.com/blog > My Photo Galleries: http://www.pbase.com/ashishpaliwal > >
-- View this message in context: http://www.nabble.com/Datagram-Socket-Binding-Problem-tp22953211p22969185.html Sent from the Apache MINA User Forum mailing list archive at Nabble.com.
