Problems getting a server / client opening Streams between themselves
I've kept working on my chat program, but now, after the client connects to the server, it won't open the ObjectInputStream and ObjectOutputStream I try to open...
Here is the current coding of my program..
NetTalkServer.java
package Dalzhim.NetTalk;
import java.io.*;
import java.net.*;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class NetTalkServer extends Thread implements WindowListener
JFrame window;
Container mainPane;
ServerSocket server = null;
boolean running = true;
boolean wait;
static Vector Users,UsersNames;
static JList dataList;
ObjectOutputStream oos;
ObjectInputStream ois;
static NetTalkInput[] connections;
int connectionsAmount = 0;
public static void main(String args[])
NetTalkServer nettalkserver = new NetTalkServer();
public NetTalkServer()
window = new JFrame("NetTalkServer");
mainPane = window.getContentPane();
Users = new Vector();
UsersNames = new Vector();
dataList = new JList(UsersNames);
JScrollPane scroll = new JScrollPane(dataList);
Dimension dimension = new Dimension(190,90);
mainPane.add(scroll);
scroll.setPreferredSize(dimension);
UsersNames.clear();
Image icon = Toolkit.getDefaultToolkit().getImage(getClass().getResource("NetTalkServer.jpg"));
window.setIconImage(icon);
connections = new NetTalkInput[255];
window.addWindowListener(this);
window.pack();
window.setVisible(true);
try
server = new ServerSocket(37148);
this.start();
catch(IOException e)
System.out.println("Error listening on socket 37148");
public void run()
Socket clientsocket = null;
while(running)
try
connections[connectionsAmount] = new NetTalkInput(server.accept(),connectionsAmount,"Server");
connectionsAmount += 1;
connections[connectionsAmount - 1].sendData(new NetTalkData("Login"));
catch(IOException e)
System.out.println("Connection attempt failed");
public static void readInput(int connection)
NetTalkData data = connections[connection].getInput();
if(data.getDataType().equals("NetTalkUser"))
NetTalkUser user = data.getDataUser();
Users.add(user);
UsersNames.add(user.getUserName());
dataList.setListData(UsersNames);
public void windowActivated(WindowEvent e)
public void windowClosed(WindowEvent e)
public void windowClosing(WindowEvent e)
this.stop();
try
server.close();
catch(IOException f)
System.exit(0);
public void windowDeactivated(WindowEvent e)
public void windowDeiconified(WindowEvent e)
public void windowIconified(WindowEvent e)
public void windowOpened(WindowEvent e)
NetTalkConnect.java
package Dalzhim.NetTalk;
import java.io.*;
import java.net.*;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class NetTalkConnect
JFrame window;
Container mainPane;
static JTextField serverIP,loginName;
JButton connect;
Socket socket;
static NetTalkInput connection;
public static void main(String args[])
NetTalkConnect connection = new NetTalkConnect();
public NetTalkConnect()
window = new JFrame("NetTalk");
mainPane = window.getContentPane();
mainPane.setLayout(null);
serverIP = new JTextField("Server IP",20);
loginName = new JTextField("Login Name",20);
connect = new JButton("Connect");
AL al = new AL();
serverIP.addActionListener(al);
loginName.addActionListener(al);
connect.addActionListener(al);
serverIP.setBounds(5,5,185,20);
loginName.setBounds(5,30,185,20);
connect.setBounds(5,55,185,20);
mainPane.add(serverIP);
mainPane.add(loginName);
mainPane.add(connect);
Image icon = Toolkit.getDefaultToolkit().getImage(getClass().getResource("NetTalk.jpg"));
window.setIconImage(icon);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.pack();
window.setVisible(true);
window.setResizable(false);
window.setSize(200,105);
serverIP.requestFocus();
serverIP.selectAll();
public static void readInput()
NetTalkData data = connection.getInput();
if(data.getDataType().equals("Login"))
connection.sendData(new NetTalkData(new NetTalkUser(loginName.getText(),connection.getUserID())));
class AL implements ActionListener
public void actionPerformed(ActionEvent e)
if(e.getSource()==serverIP)
loginName.requestFocus();
loginName.selectAll();
else if(e.getSource()==loginName)
connect.doClick();
else if(e.getSource()==connect)
connection = new NetTalkInput(serverIP.getText(),"Client");
NetTalkInput.java
package Dalzhim.NetTalk;
import java.io.*;
import java.net.*;
import java.awt.*;
import java.util.*;
public class NetTalkInput extends Thread implements Serializable
Socket userSocket;
int userID;
String userName;
ObjectInputStream ois;
ObjectOutputStream oos;
boolean running = true;
NetTalkUser user;
NetTalkData data;
String creator;
public NetTalkInput(Socket socket,int ID,String main)
try
userSocket = socket;
userID = ID;
creator = main;
ois = new ObjectInputStream(userSocket.getInputStream());
oos = new ObjectOutputStream(userSocket.getOutputStream());
System.out.println("Connection attempt succeeded");
this.start();
catch(IOException e)
public NetTalkInput(String serverIP, String main)
try
userSocket = new Socket(serverIP,37148);
creator = main;
ois = new ObjectInputStream(userSocket.getInputStream());
oos = new ObjectOutputStream(userSocket.getOutputStream());
this.start();
catch(IOException e)
System.out.println("Error connecting to server");
public void run()
while(running)
try
data = (NetTalkData)ois.readObject();
if(creator.equals("Server"))
NetTalkServer.readInput(userID);
else if(creator.equals("Client"))
NetTalkConnect.readInput();
catch(IOException e)
catch(ClassNotFoundException e)
public void sendData(NetTalkData sentData)
try
oos.writeObject(sentData);
catch(IOException e)
public NetTalkData getInput()
return data;
public int getUserID()
return this.userID;
NetTalkData.java
package Dalzhim.NetTalk;
import java.io.*;
public class NetTalkData extends Object implements Serializable
String dataType;
String dataArgument;
NetTalkUser dataUser;
public NetTalkData()
public NetTalkData(String type)
dataType = type;
public NetTalkData(String type, String argument)
dataType = type;
dataArgument = argument;
public NetTalkData(NetTalkUser user)
dataType = "NetTalkUser";
dataUser = user;
public String getDataType()
return this.dataType;
public NetTalkUser getDataUser()
return this.dataUser;
NetTalkUser.java
package Dalzhim.NetTalk;
import java.io.*;
import java.net.*;
public class NetTalkUser extends NetTalkData implements Serializable
String userName;
InetAddress userIP;
int userPort;
int userID;
public NetTalkUser(String name)
userName = name;
public NetTalkUser(String name,int ID)
userName = name;
userID = ID;
public NetTalkUser(String name,InetAddress IP)
userName = name;
userIP = IP;
public NetTalkUser(String name,InetAddress IP,int Port)
userName = name;
userIP = IP;
userPort = Port;
public String getUserName()
return this.userName;
public InetAddress getUserIP()
return this.userIP;
public int getUserPort()
return this.userPort;
public boolean equals(Object anObject)
if(anObject==null)
return false;
if (!(anObject instanceof NetTalkUser))
return false;
NetTalkUser user = (NetTalkUser)anObject;
if(!user.getUserName().equals(getUserName()))
return false;
return true;
public int getID()
return this.userID;
public void setID(int ID)
this.userID = ID;
}If you wish to try it by yourself to see exactly the problem I get, just give me your mail adress so I can send out the Java files..
Thanks in advance!
I've put the 5 java source files at those adresses:
http://www.majinnet.com/ss/Java/Chat/NetTalkServer.java
http://www.majinnet.com/ss/Java/Chat/NetTalkConnect.java
http://www.majinnet.com/ss/Java/Chat/NetTalkInput.java
http://www.majinnet.com/ss/Java/Chat/NetTalkData.java
http://www.majinnet.com/ss/Java/Chat/NetTalkUser.java
Similar Messages
-
Problems getting Lion server down from App store
I have a Mac mini server runing Snowleopard server just fine. Tried upgrading to Lion via the App store - OSX 10.7.4 came down fine - but not the server extension.
I end up in a loop where OSX10.7.4 won' install because the server extension is not avilable, and can't download Liion server extensions from the App store because 10.7.4 is not installed.
Any one know how to get the server extensions down before installing Lion so the install gets going?
Cheers,
GlenHey Glen -
I'm not at all sure why you're getting these errors, as I've followed this upgrade path just this week; but with a difference, I upgraded a client SL Mac (not server).
I'm going to suggest this - and you may even be able to do it at your local apple store with a Genius present.
Find another Lion machine and log into the app store on the account that bought Lion. Find Lion and click the download button. It'll tell you that you purchased before and you won't be charged again - let it roll. The download will proceed and when finished, will start the installer. At that point quit the installer.
Do the same with Lion Server; download again at it's App Store page.
Come prepared with a nice fat USB Stick. Copy both Installers onto the stick. They'll be in the Applications folder on this Mac.
Go to your SL Server, which MUST be at least 10.6.8.
Copy both files to the Applications folder. If there's an old Lion installer in there, overwrite it; you just got the latest build that way.
After copying to Applications, the Server installer will be greyed out and have a disable icon across it. That's normal; it can't run on anything less than 10.7. It just needs to sit there right now.
Run the Lion installer - client, that is.
It'll restart at some point - and then, because you have copied the server installer to Applications already, it will see that you want it to be a Server upgrade and will start quizzing you a bit about your setup and roll over your existing settings where it sees them.
When it's done you'll see your familiar login screen. And yes, it's server! Even though About This Mac says its 10.7.4- it really is Server. Start the Server App (not Server Admin app) and you'll see the new interface.
Server tools for Lion is a seperate download, so trash any SL versions at this point. You can DL the new ones anytime if you have a hankering for fine tweaking, but you're pretty good right out of the gate with just Server app.
Hope this helps. I've basically quoted a lesson from the Lynda.com Lion Server tutorial. Just a satisfied customer.
Tony -
Problems Reading SSL server socket data stream using readByte()
Hi I'm trying to read an SSL server socket stream using readByte(). I need to use readByte() because my program acts an LDAP proxy (receives LDAP messages from an LDAP client then passes them onto an actual LDAP server. It works fine with normal LDAP data streams but once an SSL data stream is introduced, readByte just hangs! Here is my code.....
help!!! anyone?... anyone?
1. SSL Socket is first read into " InputStream input"
public void run()
Authorization auth = new Authorization();
try {
InputStream input = client.getInputStream();
while (true)
{ StandLdapCommand command;
try
command = new StandLdapCommand(input);
Authorization t = command.get_auth();
if (t != null )
auth = t;
catch( SocketException e )
{ // If socket error, drop the connection
Message.Info( "Client connection closed: " + e );
close( e );
break;
catch( EOFException e )
{ // If socket error, drop the connection
Message.Info( "Client connection close: " + e );
close( e );
break;
catch( Exception e )
//Way too many of these to trace them!
Message.Error( "Command not processed due to exception");
close( e );
break;
//continue;
processor.processBefore(auth, command);
try
Thread.sleep(40); //yield to other threads
catch(InterruptedException ie) {}
catch (Exception e)
close(e);
2 Then data is sent to an intermediate function
from this statement in the function above: command = new StandLdapCommand(input);
public StandLdapCommand(InputStream in) throws IOException
message = LDAPMessage.receive(in);
analyze();
Then finally, the read function where it hangs at "int tag = (int)din.readByte(); "
public static LDAPMessage receive(InputStream is) throws IOException
* LDAP Message Format =
* 1. LBER_SEQUENCE -- 1 byte
* 2. Length -- variable length = 3 + 4 + 5 ....
* 3. ID -- variable length
* 4. LDAP_REQ_msg -- 1 byte
* 5. Message specific structure -- variable length
DataInputStream din = new DataInputStream(is);
int tag = public static LDAPMessage receive(InputStream is) throws IOException
* LDAP Message Format =
* 1. LBER_SEQUENCE -- 1 byte
* 2. Length -- variable length = 3 + 4 + 5 ....
* 3. ID -- variable length
* 4. LDAP_REQ_msg -- 1 byte
* 5. Message specific structure -- variable length
DataInputStream din = new DataInputStream(is);
int tag = (int)din.readByte(); // sequence tag// sequence tag
...I suspect you are actually getting an Exception and not tracing the cause properly and then doing a sleep and then getting another Exception. Never ever catch an exception without tracing what it actually is somewhere.
Also I don't know what the sleep is supposed to be for. You will block in readByte() until something comes in, and that should be enough yielding for anybody. The sleep is just literally a waste of time. -
Problems getting Web server to connect with LDAP server.
Have 4.1.8 iplanet Web and 4.13 LDAP running on Win2000 sp2. Both are working fine separately, i.e. 'have good anonymous LDAP://URL responses, and 'have working application CGI responses from web server. 'Have previously had same setup running on another server. However, with this install on win2000 cannot get Global settings LDAP feature to work ~ getting " An error occured while contacting th LDAP server. A connection to the the directory server could not be opened. Have checked DNS settings, etc. All seems to be in order. Any suggetions?
Hi,
What edition of Win 2K are you using (Pro/Server/Ad Server). The problem could be your DNS settings only.Ensure which machine is your DNS Server is running,is it on NT? if so change it to win 2K server.
Delete your LDAP machines A record from DNS server and add it again. This will solve your problem.
Refer the URL :
http://knowledgebase.iplanet.com/ikb/kb/articles/5135.html -
Problem getting from server when there are large attachments
Hello,
Using mail I have problems downloading pop mail from the server if there are messages with "large" (10MB) attachments. To solve the problem I have to login via webmail and delete the messages,. This has happened twice already. Using outlook via windows I have no such problems.
During these blocks no mail gets through, it's like the mail app does not see mail on the server.
Any solutions?
Thank you,
Fred"String to IP" can be configured to return multiple (all) addresses. Just right-click the primitive and select "Multiple Output". You can then use IP to String to get the IP addresses in a more readable form.
To know which of the 2 is the connection to your server you need to have some knowledge. If you know it starts with "10." you can just pick the IP address that matches this pattern. -
ASA 5505 (8.3+): Problems getting internal server NAT'd properly
I have an internal VOIP voicemail/presence server I want accessible from outside my internal network. Connecting internally works great, but when a user tries connecting from outside, there's no availability. When I try to use NAT, the voicemail-to-email service can't reach our cloud email service.
We have a /28 public IP address range. The ASA is our external device, the WAN side is .220, with our ISP's gateway set at .222. I've tried NATting the server to a .217 address, but that's when things go wrong.
With the current config, our VM-to-email works. Here's some snippets of my config:
ASA Version 9.0(3)
xlate per-session deny tcp any4 any4
xlate per-session deny tcp any4 any6
xlate per-session deny tcp any6 any4
xlate per-session deny tcp any6 any6
xlate per-session deny udp any4 any4 eq domain
xlate per-session deny udp any4 any6 eq domain
xlate per-session deny udp any6 any4 eq domain
xlate per-session deny udp any6 any6 eq domain
interface Vlan1
nameif inside
security-level 100
ip address 192.168.200.1 255.255.255.0
interface Vlan2
nameif outside
security-level 0
ip address xxx.xxx.xxx.220 255.255.255.248
object network OUTSIDE
host xxx.xxx.xxx.220
object network INSIDE
subnet 192.168.200.0 255.255.255.0
object network VMSERVER
host 192.168.200.59
object network VMSERVER_PUBLIC
host xxx.xxx.xxx.217
object service VMSERVER_Bitmessage
service tcp source eq 8444 destination eq 8444
description Bitmessage
object service VMSERVER_XMPP_client
service tcp source eq 5222 destination eq 5222
description Extensible Messaging and Presence Protocol (client)
object service VMSERVER_XMPP_server
service tcp source eq 5269 destination eq 5269
description Extensible Messaging and Presence Protocol (server)
object service VMSERVER_HTTP
service tcp source eq 8080 destination eq 8080
object-group service VMSERVER
service-object object VMSERVER_Bitmessage
service-object tcp-udp destination eq 5222
service-object tcp-udp destination eq 5269
service-object object VMSERVER_HTTP
access-list INBOUND extended permit object-group VMSERVER any4 object VMSERVER
no arp permit-nonconnected
nat (inside,outside) source static VMSERVER VMSERVER destination static OUTSIDE OUTSIDE service VMSERVER_XMPP_client VMSERVER_XMPP_client no-proxy-arp
nat (inside,outside) source static VMSERVER VMSERVER destination static OUTSIDE OUTSIDE service VMSERVER_XMPP_server VMSERVER_XMPP_server no-proxy-arp
nat (inside,outside) source static VMSERVER VMSERVER destination static OUTSIDE OUTSIDE service VMSERVER_Bitmessage VMSERVER_Bitmessage no-proxy-arp
nat (inside,outside) source static VMSERVER VMSERVER destination static OUTSIDE OUTSIDE service VMSERVER_HTTP VMSERVER_HTTP no-proxy-arp
object network INSIDE
nat (inside,outside) dynamic interface
access-group INBOUND in interface outside
route outside 0.0.0.0 0.0.0.0 xxx.xxx.xxx.222 1
It seems to me that it's a NAT issue, but I could be wrong. If I try adding a static route for the public address for the server, the VM-to-email stops working. And, the presence server still doesn't work externally.
Any help is appreciated,
LaneRPacket tracer output to mapped (public) address:
ASA# packet-tracer input outside tcp 1.1.1.1 8080 xxx.xxx.xxx.217 8080 detailed
Phase: 1
Type: UN-NAT
Subtype: static
Result: ALLOW
Config:
object network VMSERVER
nat (inside,outside) static xxx.xxx.xxx.217
Additional Information:
NAT divert to egress interface inside
Untranslate xxx.xxx.xxx.217/8080 to 192.168.100.59/8080
Phase: 2
Type: ROUTE-LOOKUP
Subtype: input
Result: ALLOW
Config:
Additional Information:
in 0.0.0.0 0.0.0.0 outside
Phase: 3
Type: ACCESS-LIST
Subtype: log
Result: ALLOW
Config:
access-group INBOUND in interface outside
access-list INBOUND extended permit tcp any any eq 8080
Additional Information:
Forward Flow based lookup yields rule:
in id=0xcd332f78, priority=13, domain=permit, deny=false
hits=1, user_data=0xc922afc0, cs_id=0x0, use_real_addr, flags=0x0, proto
col=6
src ip/id=0.0.0.0, mask=0.0.0.0, port=0, tag=0
dst ip/id=0.0.0.0, mask=0.0.0.0, port=8080, tag=0 dscp=0x0
input_ifc=outside, output_ifc=any
Phase: 4
Type: NAT
Subtype: per-session
Result: ALLOW
Config:
Additional Information:
Forward Flow based lookup yields rule:
in id=0xc7668a30, priority=1, domain=nat-per-session, deny=true
hits=1294404, user_data=0x0, cs_id=0x0, reverse, use_real_addr, flags=0x
0, protocol=6
src ip/id=0.0.0.0, mask=0.0.0.0, port=0, tag=0
dst ip/id=0.0.0.0, mask=0.0.0.0, port=0, tag=0 dscp=0x0
input_ifc=any, output_ifc=any
Phase: 5
Type: IP-OPTIONS
Subtype:
Result: ALLOW
Config:
Additional Information:
Forward Flow based lookup yields rule:
in id=0xcb250c18, priority=0, domain=inspect-ip-options, deny=true
hits=837081, user_data=0x0, cs_id=0x0, reverse, flags=0x0, protocol=0
src ip/id=0.0.0.0, mask=0.0.0.0, port=0, tag=0
dst ip/id=0.0.0.0, mask=0.0.0.0, port=0, tag=0 dscp=0x0
input_ifc=outside, output_ifc=any
Phase: 6
Type: VPN
Subtype: ipsec-tunnel-flow
Result: ALLOW
Config:
Additional Information:
Forward Flow based lookup yields rule:
in id=0xcbbc8378, priority=13, domain=ipsec-tunnel-flow, deny=true
hits=697, user_data=0x0, cs_id=0x0, flags=0x0, protocol=0
src ip/id=0.0.0.0, mask=0.0.0.0, port=0, tag=0
dst ip/id=0.0.0.0, mask=0.0.0.0, port=0, tag=0 dscp=0x0
input_ifc=outside, output_ifc=any
Phase: 7
Type: NAT
Subtype: rpf-check
Result: ALLOW
Config:
object network VMSERVER
nat (inside,outside) static xxx.xxx.xxx.217
Additional Information:
Forward Flow based lookup yields rule:
out id=0xcd333dc0, priority=6, domain=nat-reverse, deny=false
hits=3, user_data=0xcaaa0950, cs_id=0x0, use_real_addr, flags=0x0, proto
col=0
src ip/id=0.0.0.0, mask=0.0.0.0, port=0, tag=0
dst ip/id=192.168.100.59, mask=255.255.255.255, port=0, tag=0 dscp=0x0
input_ifc=outside, output_ifc=inside
Phase: 8
Type: NAT
Subtype: per-session
Result: ALLOW
Config:
Additional Information:
Reverse Flow based lookup yields rule:
in id=0xc7668a30, priority=1, domain=nat-per-session, deny=true
hits=1294406, user_data=0x0, cs_id=0x0, reverse, use_real_addr, flags=0x
0, protocol=6
src ip/id=0.0.0.0, mask=0.0.0.0, port=0, tag=0
dst ip/id=0.0.0.0, mask=0.0.0.0, port=0, tag=0 dscp=0x0
input_ifc=any, output_ifc=any
Phase: 9
Type: IP-OPTIONS
Subtype:
Result: ALLOW
Config:
Additional Information:
Reverse Flow based lookup yields rule:
in id=0xcb227388, priority=0, domain=inspect-ip-options, deny=true
hits=858219, user_data=0x0, cs_id=0x0, reverse, flags=0x0, protocol=0
src ip/id=0.0.0.0, mask=0.0.0.0, port=0, tag=0
dst ip/id=0.0.0.0, mask=0.0.0.0, port=0, tag=0 dscp=0x0
input_ifc=inside, output_ifc=any
Phase: 10
Type: FLOW-CREATION
Subtype:
Result: ALLOW
Config:
Additional Information:
New flow created with id 856605, packet dispatched to next module
Module information for forward flow ...
snp_fp_tracer_drop
snp_fp_inspect_ip_options
snp_fp_tcp_normalizer
snp_fp_translate
snp_fp_adjacency
snp_fp_fragment
snp_ifc_stat
Module information for reverse flow ...
snp_fp_tracer_drop
snp_fp_inspect_ip_options
snp_fp_translate
snp_fp_tcp_normalizer
snp_fp_adjacency
snp_fp_fragment
snp_ifc_stat
Result:
input-interface: outside
input-status: up
input-line-status: up
output-interface: inside
output-status: up
output-line-status: up
Action: allow
Actually using a browser and port 8080, no access... -
Problems Getting My Video to Open in IMovie 09
Hey everyone,
I have an avi file that I am trying to open in IMovie and the icons/movie frames are not showing up and it is telling me to "Choose a different option from the Show option menu." I tried all four options and nothing will come up. I can convert the file to any format, so maybe the format is bad? Thank you for your help!Try converting it to .mov, if that's possible. .avi was originally a Window format, and iMovie might not like it
-
Data streaming between server and client does not complete
Using an ad-hoc app, data streaming between server
and client does not complete as it supposed to be.
The process runs well in solaris 5.8, however under 5.9
we have found the characters stream buffer length limitation
is around 900 to 950 characters (by default we are using 3072
characters).
Example:
- We are transfering HTML file, which will be displayed
in the App client, with buffer=3072, the HTML only displayed / transfered
as xxxxxxxx characters, but with buffer=900 the HTML is displayed properly,
in this case, the only problem that we have is the file transfer will
eventually longer than usual.
- There is another case, where we have to transfer information (data) as stream
to the client. A long data stream will not appear at all in the client.
Any ideas why the change between 5.8 and 5.9 woudl cause problems?
The current app-driver that we are using is compiled using Solaris 5.6,
if possible we would like to have use of a later version, which is compiled using Solaris 5.9, do you think this will probably solve our problem?
Thanks
PaulDoes this have anything to do with Java RMI? or with Java come to think of it?
-
Managing stream between java server and c client
Hi all
I'm working on a client/server application.
Client have been written in C
Server is in Java.
The client connect to the server, send a message (unknown size) and wait a response from the server.
The server on connection start a new thread. This thread try to read data from the socket, using a BufferedInputStream :
BufferedInputStream in = new BufferedInputStream(socket.getInputStream());
As far as I dont know the size of the incoming message, i use the folowing algorythme to read data :
byte[] bytesLus = new byte[1000];
byte[] tmpBytesLus;
byte[] tousLesBytes;int nb;
i = 0;
tousLesBytes = new byte[0];
Log.trace(sourceTag,"Lecture des premiers octets");
nb=in.read(bytesLus,0,bytesLus.length);
Log.trace(sourceTag,nb+"octets lus");
while (nb>0){
tmpBytesLus = new byte[i+nb];
System.arraycopy(tousLesBytes,0,tmpBytesLus,0,tousLesBytes.length);
System.arraycopy(bytesLus,0,tmpBytesLus,tousLesBytes.length,nb);
tousLesBytes = tmpBytesLus;
i = i+nb;
bytesLus = new byte[1000];
Log.trace(sourceTag,"nb octets lus : " + i);
if (in.available()>0)
nb=in.read(bytesLus,0,bytesLus.length);
else
nb=0;
This seemed (but only seemed - i will explain it later) to work fine :
the client send a 6300 bytes sized msg. Server receive it, treat it and send response back. and this at each try.
But when i change the log level of the server from TRACE to ERROR (wich have on consequence to accelerate the instruction Log.trace( ... ) the server doesn't work so fine !
On first try, everything is ok, but on second, client send the same 6300 bytes msg, but server consider receiving only 3000 !
After debbuging, i found why :
the reason is the use of :
if (in.available()>0)
If you are reading faster than the writer, there is a moment where the stream is in a blocking state for the reader. and in.available return the number of bytes you can read before blocking...
So my server consider that it reached the end of the message....
So, after this long introduction, here my question :
What is the best way to detect the end of a stream ?
Should I send a special character on the stream and decode it on server ?
Thank's for your advice.
OlivierGenerally, there are n ways of making sure an entire message of unknown size is recieved:
1. Include some kind of validation criteria at the beginning of the message : checksum, bytecount, etc.
2. Format the message such that the server can tell when the end is reached (subject to "line noise" problems)
3. Enable two-way communication between the client and server, so they can work it out as they go.
4. Use a pre-established protocol that handles all this for you
5. Close the stream after writing if you only have one message.
6. etc etc etc. -
Getting 10.4 clients to authenticate with 10.5 server
I have a couple of older G4 clients running 10.4.11. I am trying to get them to use my 10.5 server for authentication and automatically mounting users' home directories. I can't seem to get it to work. All my 10.5 clients work fine. I am guessing a schema differences between 10.4 and 10.5 but don't know enough about LDAP to make an educated guess.
I have used Directory Access to configure LDAPv3 and configured the client alternately to use both "from server" and "open directory server". It appears that I have no trouble binding to the server but authentication does not work afterwards. Symptom is that I type in a valid username and password at the login screen, I get the pause like it is waiting for a response to the query (beachball), and then the "shake" about 15 seconds later.
I would think that there is an article somewhere that says, "here is how you make your 10.4 clients work with a 10.5 server," but searches using various keywords hasn't produced the desired result.
Thanks in advance.
Brian Lloyd
Granite Bay Montessori SchoolWell, I unbound the clients and that did not immediately solve the problem. However, I rebooted the server and now all the 10.4 clients (once unbound) are authenticating just fine.
Thank you for pointing me in the right direction.
Brian -
How can I get Address Book Server to share contacts between users?
I want to have a Shared Address Book for the users on my installation of OS X Lion Server. Users will keep their own contacts individually but there are certain lists and contacts who need to be shared between users and I can't find any way of getting Lion Server to do this. I know it was a problem in Snow Leopard Server but I hoped it had been fixed.
Any suggestions?Create a new user on the Server called 'ouraddressbook' or whatever. Exit the Server. Into Address Book on your Admin/Client machine create a new Account. Account type is CardDAV, Username and Password the same as the User you created on the Server… 'ouraddressbook' or whatever, and then enter your Server's address as text or numbers. Click creat and the rest is straight forward. Now give the set up details of that new Account to the others who want to share your 'ouraddressbook' with you.The Clients must have, I think, Mac OS 10.6 or upwards to have an Address Book that with co-operate.
You will see a new group in Address Book.
If you don't already know, do not add accounts to Address Book or iCal on the Server. Everything is Admin and Client Side. In the beginning I was also adding accounts to iCal and Address on the Server. It works fine but it is just one extra thing that could become corrupted. Let the Server 'serve' the Users you create on it.
Hit me if you have problems. -
Chaining streams between 2 media server
Hi i'm trying to setup a stream chaining between 2 flash
media servers.
Basically I have an swf that streams my camera to FS Server
1. In FS Server 1, i have the following code in the main.asc
application.onConnect = function(client, username){
gFrameworkFC.getClientGlobals(client).username = username;
application.acceptConnection(client);
application.onConnectAccept = function(client, username){
application.myRemoteConn.connect("rtmp://10.0.0.23/myapp");
// Connect to FS2
application.myRemoteConn.onStatus = function(info){
if (info.code == "NetConnection.Connect.Success" &&
application.myRemoteConn.isConnected){
application.myStream = Stream.get("foo");
if (application.myStream) {
application.myStream.play("me_live", 0, -1, true,
application.myRemoteConn);
The stream is created in FS1, and I can view it if I connect
to it with an SWF client. On the FS2 server (the server FS1 does a
NetConnection to), I can see a client connection in the Clients tab
but thats about it. If I try to connect to the FS2 server, there is
no stream displaying on the SWF client. (The SWF client just
contains a Video object which connects to the FS stream.)
Any ideas please? This may sound like a silly question, but
I'm fairly new to server side action script.
Does any one have any sample code? Is there an alternate
method of chaining a stream? I've thoroughly searched the docos but
no luck.
Thanks again.hi jay,
Thanks for your prompt reply. Yes I was actually trying that
method aswell, obviously incorrectly. My AS code on the FS2 was
this:
application.onAppStart = function(){
trace("application start called. create server side
connection");
application.remConn = new NetConnection();
application.remConn.connect("rtmp://10.0.0.77/myapp"); //
this connects to the FS1 server where a stream
// called me_live is being published
application.remConn.onStatus = function (info) {
trace("info is "+info.code);
application.myStream = Stream.get("me_live"); // this stream
is being streamed by the SWF client with a camera.
// the stream is correctly being published. i could view
this with
// another SWF client that just retrieves the video
if (application.myStream){
trace("playing stream");
application.myStream.play("me_live", -1, -1, false,
application.remConn);
I know that theres quite a number of errors on the above
code. I would've figured though that the the Stream class has a
method to retrieve a remote stream, or even in the NetConnection
object (something like
application.remConn.Stream.get("streamname")) - but of course it
can't be that easy!! Is there way of doing this? Thanks again for
your help. -
Strange problem with AIX server and windows clients
I am having a real bizzare problem with WLS 7.0.1 running on AIX 5.1 and
clients on windows. We have J2SE Swing application as a client.
If the client is w2k or XP, the first client gets good response. If I start
another client the second client is horribly slow (2 sec vs 16 sec). Even if
I kill the first client the second client continues to be slow. If I have 2
clients open together, the first one continues giving 2 sec response while
the second one continues with 16 sec. For that matter if I start another
client after shutting down first one I get slow (16 sec) response.
If the client is NT client I always get good and consistent response from
the server. Irrespective of how many client I have on the NT machine, I keep
getting good response. NT and W2K laptops are seating right next to each
other on the same n/w and infact the NT is a much slower and lessor memory
machine than W2K.
We did similar tests keeping server on Solaris or NT server or W2K server,
and the clients "behave" normally i.e I get consistent repsponse time (it
may be slow or fast, but it is consistent and is consistent b/w NT and W2K).
We even tried putting my laptop on the same network as the AIX server, but
it did not help. Unfortunately some of our clients will be using AIX and
W2K.
HELP!!!!"Cameron Purdy" <[email protected]> wrote in message
news:[email protected]..
Sounds like a reverse DNS lookup or similar network timeout.Thanks for the suggestion, but then why would the first client on w2k or XP
get a better performance and the subsequent clients get worse performance?
>
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com/coherence.jsp
Tangosol Coherence: Clustered Replicated Cache for Weblogic
"vinay moharil" <[email protected]> wrote in message
news:[email protected]..
I am having a real bizzare problem with WLS 7.0.1 running on AIX 5.1 and
clients on windows. We have J2SE Swing application as a client.
If the client is w2k or XP, the first client gets good response. If Istart
another client the second client is horribly slow (2 sec vs 16 sec).
Even
if
I kill the first client the second client continues to be slow. If I
have
2
clients open together, the first one continues giving 2 sec response
while
the second one continues with 16 sec. For that matter if I start another
client after shutting down first one I get slow (16 sec) response.
If the client is NT client I always get good and consistent responsefrom
the server. Irrespective of how many client I have on the NT machine, Ikeep
getting good response. NT and W2K laptops are seating right next to each
other on the same n/w and infact the NT is a much slower and lessor
memory
machine than W2K.
We did similar tests keeping server on Solaris or NT server or W2Kserver,
and the clients "behave" normally i.e I get consistent repsponse time(it
may be slow or fast, but it is consistent and is consistent b/w NT andW2K).
We even tried putting my laptop on the same network as the AIX server,
but
it did not help. Unfortunately some of our clients will be using AIX and
W2K.
HELP!!!! -
Problems with games server and client
Hi! I am making an MMORPG game and I have problems with the server and client connection.
I can connect to the server, but when a second player does, the server console tells me this:
java.net.SocketException: Connection reset
After that, all clients disconnect.
Which is the problem?
How can I solve it?
Thank you so muchHere is how my sever work. I took some of this code from a book called Killer Programming Games in Java. If you google for it, you will find it for sure.
TourGroup tg = new TourGroup(); // this object stores information about all clients connected to the server
try {
ServerSocket serverSock = new ServerSocket(PORT);
Socket clientSock;
while (true) {
System.out.println("Waiting for a client...");
clientSock = serverSock.accept();
new TourServerHandler(clientSock, tg).start(); // this is the thread that monitors each client
catch(Exception e)
{ System.out.println(e); }
} This is some code of TourServerHandler
public TourServerHandler(Socket s, TourGroup tg)
this.tg = tg;
clientSock = s;
name= "?";
cliAddr = clientSock.getInetAddress().getHostAddress();
port = clientSock.getPort();
System.out.println("Client connection from (" +
cliAddr + ", " + port + ")");
public void run()
// process messages from the client
try {
// Get I/O streams from the socket
BufferedReader in = new BufferedReader(
new InputStreamReader( clientSock.getInputStream() ) );
PrintWriter out =
new PrintWriter( clientSock.getOutputStream(), true );
// and here goes the rest... The TourServerHandler thread uses this code to send messages:
tg.broadcast(msg); tg.broadcast works like this:
synchronized public void broadcast(String cliAddr, int port, String msg)
// broadcast to everyone but original msg sender
TouristInfo c; // this object stores info about the client
for(int i=0; i < tourPeople.size(); i++) {
c = (TouristInfo) tourPeople.get(i);
c.sendMessage(msg);
} This is the error part
public void sendMessage(String msg)
PrintWriter out;
out.println(msg);
System.out.println("OK");
} I can't find any error but I still get that Connection reset exception... -
I am getting error when hovering on document in sharepoint online "sorry there was a problem and we can't open this document.If this happens again, try opening the document in Microsoft Word".I am sure that document is not corrupted and
all. something it showing the preview and sometimes it throwing this error. I hope this error is intermident. When clicking on the link also it throws this error but on refreshing it working fine. I dont know why it is happening. Please helpme to resolve
this issue.Hi Waqas
Thanks for your help with this. I had a look at both posts, the URL works fine from the WAC server and I am not using a System account to test docs.
Also, this is a production site that is accessible over the Internet, so we are using https therefore the WOPIZone is external-https.
Issue #3 in the above blog link does not reflect the same error I see on my servers.
I also had a look at the information in this link: http://technet.microsoft.com/en-us/library/ff431687.aspx#oauth
Problem: You receive a "Sorry, there was a problem and we can't open this document" error when you try to view an Office document in Office Web Apps.
If you added domains to the Allow List by using the
New-OfficeWebAppsHost cmdlet, make sure you’re accessing Office Web Apps from a host domain that’s in the Allow List. To view the host domains in the Allow List, on the Office Web Apps Server open the Windows PowerShell prompt as an administrator and run
the Get-OfficeWebAppsHost cmdlet. To add a domain to the Allow List, use the
New-OfficeWebAppsHost cmdlet.
I have not added any domains to the Allow list so this did not help either. Should I add the domain?
Any further help with this is much appreciated.
Thanks again.
Yoshi
Maybe you are looking for
-
I just bought a square and in order to use it I needed to download Itunes with OS1. I did it but now I have no contacts, is that normal? Are all my contacts gone for good?
-
How can I rectify a wrong command in about:config in Mozilla Firefox
Pls help me to solve below problem: In a certain blog ( http://techtips01.blogspot.com/2010_03_17_archive.html ) dated 17 March, 2010 I found in point no. 07: 7. Rather than wait until a page has completely downloaded to display it to the user, Mozil
-
Permission errors in /home
Hi, I've searched the best I could do to find a solution to this problem, but I haven't found one yet! So, on my fresh Arch install, I followed the newbie-guide and installed XFCE. I encountered a problem with permissions: First, I couldn't even star
-
Hi All also got a nokia 5800 XM and it seems mine is working fine and never got any problems yet nor aware of. im a bit expecting all of it. hehe My problem is here, i heard this pencil application and was able to download it through a wifi connectio
-
What is posting key for debit note and credit note?
Hi Gurus, May I know what is posting key for debit and credit note? My current sales debit and credit note having same posting key. Where can I set this posting key? Sales debit note dt cr Sales credit note dt