?
Solved

ServerSocket and UDP

Posted on 1997-05-11
1
Medium Priority
?
1,511 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
jpk041897 earned 300 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month8 days, 6 hours left to enroll

766 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