Solved

ServerSocket and UDP

Posted on 1997-05-11
1
1,504 Views
Last Modified: 2008-03-10
Hi,
   Can someone help me with the following problems:
   When I set up a ServerSocket and use a Socket with its stream flag set to true, everything is working fine but once I set the flag to false(ie UDP) there doesn't seem to be a connection... UDP can't be that unrealiabe since I am sending from one window(for serevr) to another(the socket). Where could I have gone wrong?
  Also if I use,eg
   OutputStream outstream = myserver.getOutputStream();
  how much data can I send thru outstream.write(mydata) before mydata is actually send out. Is there a way for me to set the system buffer?
   Is there a Java equivalent to C's union?

   Thanks.


    tm
CHAN
0
Comment
Question by:chantm
1 Comment
 
LVL 6

Accepted Solution

by:
jpk041897 earned 150 total points
ID: 1220361
1) You should be using the DatagramPacket and DatagramSocket classes. Not the Socket class with stram set to false. (this does not invoke UDP, it just stipulates that you do not want a permanent connection beteen th client and the host).

See:

http://www.inf.uni-hohenheim.de/top/java/tutorial/networking/datagrams/definition.html

and

http://www.inf.uni-hohenheim.de/top/java/tutorial/networking/datagrams/clientServer.html

for theory and sample code on how to work with UDP.

2) No way to set the system buffer, but you can set up a counter and call the streams flush() method whenever you want it to.

3) No actual equivalent, since jJava's class (as is C++'s) is related to the struct construct.

Their is a way to do it (though weathr its acceptable for your app or not is debatable).

You can derive a class from java.util.Dictionary

The dictobnary class which maps keys to values. Any object can be used as a key and/or value.  

You could therfore implement either a bag class or add an index to your union (by efectivley converting it into a struct with a union member) and work arrounf the problem.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now