Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / May 2008

Tip: Looking for answers? Try searching our database.

java socket programming doubt

Thread view: 
sam.barker0@gmail.com - 19 May 2008 14:42 GMT
Hi All,
I am trying to create a udp socket.
It works fine but the program hhangs for a few seconds[at
DatagramSocket clientSocket = new DatagramSocket();] before ti
actually sends the data out.Could any one tell me why?

try
        {

            System.out.println("Creating datagram");
            DatagramSocket clientSocket = new DatagramSocket();

            InetAddress IPAddress =
                   InetAddress.getByName("localhost");
               byte[] sendData;
               byte[] receiveData = new byte[1024];
               String sentence ="TEST";
               sendData = sentence.getBytes();
               DatagramPacket sendPacket =
                   new DatagramPacket(sendData, sendData.length,
                                      IPAddress, 9876);
               clientSocket.send(sendPacket);

}
Cheers,
Sam
GArlington - 20 May 2008 11:11 GMT
On May 19, 2:42 pm, sam.bark...@gmail.com wrote:
> Hi All,
> I am trying to create a udp socket.
[quoted text clipped - 23 lines]
> Cheers,
> Sam

It doe NOT [your code copied into main] for me. So check the rest of
your code...
BTW: why do you think that it hangs there? (and NOT somewhere else)?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.