Solved

ServerSocket and UDP

Posted on 1997-05-11
1
1,505 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

911 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

23 Experts available now in Live!

Get 1:1 Help Now