Networking problem with server

Hi i a have developed a client server application,where a students logs in using agui to aestablish a connection with the server.When mu server is up and running waiting for clients and when i run my client program and the GUI appears then the folowing error appears on my server outpurt
java.lang.ArrayIndexout of bounds exception
at lines,38,69,and 151.Here is my server code
import java.io.*;
import java.net.*;
import java.util.Random;
public class Server extends Thread {
//private static final int portnumber = 4444;
private static final int waitforclient = 0;//represents when the server is idle and is waiting for a client connection
private static final int waitforanswer = 1;//
private static final int waitforconfirm = 2;//represents the server waiting for conformation from client
private ServerSocket serverSocket; //keeps up with the server-socket connection
private String[] questions;
private JDBC jdbc;
private int numQuestions; //stores the number of questions
private int num = 0; //num is the number of the current question been asked
private int state = waitforclient; //hold the cueent state of the server
private Random rand = new Random(); //pick questions at random
//creating server socket
public Server(){
super("Server");
try{
serverSocket = new ServerSocket(4444);
System.out.print("Socket created and server now waits for clients");
catch (IOException e)
System.out.print("Error:couldn't create socket");
System.exit(1);
public static void main(String[] args){
Server obj = new Server();
obj.run();
public void run(){
Socket client = null;
if (!initQnA()){
System.out.println("couldn't initialise questions");
return;
while (true){
if (serverSocket==null)
return;
try{
client = serverSocket.accept();
jdbc = new JDBC();
jdbc.getPassword();
catch(IOException e){
System.out.println("couldn't connect to client socket");
System.exit(1);
try
InputStreamReader isr =new InputStreamReader(client.getInputStream());
BufferedReader is = new BufferedReader(isr);
PrintWriter os = new PrintWriter(new BufferedOutputStream(client.getOutputStream()),false);
String outLine;
outLine = processInput(null); //communication between the client and server is handdddled by this method
os.println(outLine);
os.flush();
while (true){
String inLine = is.readLine();
if(inLine.length() > 0){
outLine = processInput(inLine);
os.println(outLine);
os.flush();
if(outLine.equals("invalid"))
break;
//Clean up
os.close();
is.close();
client.close();
catch(Exception e){
System.err.println("Exception: "+e);
e.printStackTrace();
private boolean initQnA(){
try{
File infile = new File("password.txt");
FileInputStream inStream = new FileInputStream(infile);
byte[] data = new byte[(int)infile.length()];
if (inStream.read(data) <= 0){
System.err.println("error: couldn't read file");
return false;
//used to find the number of users
for (int i=0; i< data.length; i++) {
if (data[i] == (byte)'\n') {
numQuestions++;
questions = new String[numQuestions];
//stores the users in a array called questions
int start = 0, index = 0;
for (int j=0; j< data.length; j++) {
if (data[j] == (byte)'\n'){
questions[index] = new String(data, start, j-start-1);
index++;
start =j+1;
catch (FileNotFoundException e){
System.err.println("Exception: couldn't find the question file");
return false;
catch(IOException e){
System.err.println("Exception: io error");
return false;
return true;
String processInput(String inStr){//Each case stement in process statement reperesents
                                                       //the server leaving the given state
String outStr = null;
switch (state){
case waitforclient:
outStr = questions[num];
state = waitforanswer;
break;
case waitforanswer:
outStr = "invalid";
//int con = inStr.charAt('=');
//String re = inStr.substring(0,con);
for (int y=0; y< numQuestions; y++){
System.out.println(inStr);
if (inStr.equalsIgnoreCase(questions[y])){
outStr = "valid";
System.out.println("valid user");
break; // if he is a valid user then create a txt file using his username as the name of the file
case waitforconfirm:
if (inStr.equalsIgnoreCase("stop server")){
state = waitforclient;
num = Math.abs(rand.nextInt())%
questions.length;
outStr = questions[num];
state = waitforanswer;
else{
//outStr ="Bye";
state = waitforclient;
break;
return outStr;
}

Line 38? I'm not about to count lines in your code. You find line 38 yourself. You'll find it has an array index taking place in it somewhere. That index is either less than zero or greater than or equal to the array size. If you want to post this again, please do us the courtesy of indicating those lines and formatting the code properly.

Similar Messages

  • Networking Problems with Server 2008 r2

    Has anyone been able to successfully install Windows Server 2008 on a Mini Server running Lion? I know the native Boot Camp assistant only supports Windows 7, but I was able to install it using 3.0.1. I've been able to get it running but can't get Windows to recognize my network adapter. Any ideas?

    Make sure you have proper network setting (VPN etc) when accessing server share.
    Regards, Ravikumar P

  • Network problem with vodafone in india, noida

    network pronlem in my iphone 5 for last 8months, please advise what to do?.

    What problem?
    Any network problem with your cell phone carrier you need to take up with the carrier.

  • Tried opening Firefox and got error code 502 - problem with server - how do i fix please

    i tried to open internet through Firefox as usual and got repeated error message 502 (problem with server - try again in 30 seconds) - but no joy. is there a problem with the server or is there a problem at my end somehow?
    tks Paul

    Thanks for the suggestion Rhonda. You're correct in saying this is impractical though. The fact is, I can't open a tab to keep it open. After doing some online research, I was able to locate a site where I could download a previous Firefox version (6.0). Problem solved! Google: "''How can I find a previous version of Firefox''. As I stated in my original question, Mozilla should not update w/o making certain it doesn't create these issues. I spent hours on this. I also turned off auto updates. I appreciate your suggestion. Thank you!

  • I cannot sign in to icloud because of problems with server

    I have Lost It All!
    I cannot find all of my iTunes info.
    I tried signing into iCloud due to a message "problem with server".

    I have used the solution below to fix mine and others that have run into this issue.
    Start --> Programs --> Accessories (Right Click on Command Prompt) --> Run as Administrator
    then type in:  "Netsh winsock reset"  (-without the quotes-)
    Hit enter, restart PC, iCloud For PC should now connect without any server errors
    (This solutions will work in some instances when trying to fix errors associated when you are unable to connect to iTunes also.)

  • Why my Ipod send a message like "a problem with server bloq connection of ID Apple"

    Hi i just buy an Ipod Touch 8GB is my second one the last one have lost in the street, i Know my Apple ID and my password but when Itry to setup the new one send that message i am from mexico and my message is in spanish more less like this Impossible start session A problem with server is bloking the connection with the ID Apple . Try to connect again.

    What is the error message you are receiving and it is from iTunes or your iPod Touch?
    B-rock

  • Facing network problem with iPhone 5s after updating it to iOS 7.1.2 .

    Facing network problem with iPhone 5s after updating it to iOS 7.1.2 , using Vodafone in india. if at one place network is full then after few minutes at same place i get no network ? what can be done ?

    Hi srikka,
    I'm sorry to hear about the issues you've been having with the iOS 8 upgrade on your iPhone 5s; I know how frustrating that can be, especially on a device you use every day like a smartphone. If you continue to have issues with your WiFi and cellular data connections, you may find the troubleshooting steps outlined in the following articles helpful:
    iOS: Troubleshooting Wi-Fi networks and connections - Apple Support
    iPhone cellular data connection issues - Apple Support
    Regards,
    - Brenden

  • Problem with Server Pool

    Hello,
    I have an pool of physical servers at the company that supports the production environment of virtual servers.
    This pool have 4 (0, 1, 2 and 3) domain servers.
    I recently had a problem with the OVS-AGENT, and had to restart the whole pool.
    After that, all virtual servers I start at the pool, using the VM Manager, always start at the same domain server, the domain number 3.
    When I force the start using xm create, I can start the virtual server at domain server 0, 1 and 2 too.
    The live migration only works with the shell command (xm migrate -l), using the VM Manager simple do nothing.
    I try to force an especific virtual machine to run at an especific node, using Placement Policy at VM Manager, but when I try to start the server, this error occurs:
    Start - /OVS/running_pool/441_n_psgl04
    PowerOn Failed : Result - failed:errcode=20000, errmsg=No enough memory to run vm(/OVS/running_pool/441_n_psgl04), required memory=16384.
    StackTrace:
    File "/opt/ovs-agent-2.3/OVSSiteVM.py", line 124, in start_vm
    raise e
    Any idea what's happening? Is that some problem with the ovs-agent's database? How can I fix that with minimum of outage of the virtual servers?
    I'm really concerned about this problem because this weekend we had a stop on the network that caused the restart of the cluster, and when the servers came back, all virtual servers started up on the same physical server, which caused a lack of resources.
    Thanks for your help, and sorry about my poor english!

    843474 wrote:
    PowerOn Failed : Result - failed:errcode=20000, errmsg=No enough memory to run vm(/OVS/running_pool/441_n_psgl04), required memory=16384.You don't have enough memory on the target server to start this guest. So, you need to work out why you don't have enough memory or why Oracle VM Manager isn't seeing all your servers. Check to see if all the servers are listed as "Active" on the servers tab of Oracle VM Manager. Also, you can try and restore the ovs-agent database to the entire pool by clicking the "Restore" button on the Server Pools tab.

  • Networking problems with OS 10.4.6

    My server is a G3 iMac on OS 9.1 networked with a G4 on OS 10.4.6. Prior to installing 10.4.6 I could connect with the G3 iMac. Now I cannot.
    Are there other reports of connection problems with 10.4.6?
    Anybody have a solution?
    Thanks.
    trl
    iMac G3   Mac OS 9.1.x  

    Point taken but this is not just a Quark question. I have been told that 10.4.6 has problems with Extensis X1.
    Kind of silly to put out thousands for a computer and not to have it work with certain programs.

  • Network Problems with iOS 6.1 and iPhone 5

    I strongly believe that the network connections with iOS6 and my iPhone5 has serious problems. I am experiencing the following issues;
    Weak wifi signal at locations where I was enjoying good connection with iOS 6.0.1
    Sometime when I enter into a known wifi area, the phone does not connect to wifi automatically. I have to open the Settings App and go to wifi section to get it connected.
    Sometimes when I wake-up my phone from sleep, which is sleeping well within wifi range, it shows 3G connection and take some times to get connected to wifi.
    I am experiencing fast battery draining when compared to my phone with iOS 6.0.1
    FYI, I have already tried resetting my network settings and done hard restarting many times without success.
    Please advice any action to solve the problems.
    FYI, I have submitted the above to Apple via Apple feedback page.

    I am having the same issues with an iPhone 5 and it all started when I upgraded to iOS6.1.  I geat a strong wifi signal all 3 bars showing and speedtest shows a 20Mps upload and download connection (I have BT Infinity up to 70Mbps connection), however when I go onto safari or even simplae apps like weather or Sky News I am unable to connect  - regularly getting the message "Cannot connect to .... a wifi or 3G connection is required.  Occasionally it will work say 5% of the time bit having to switch to 3G and luckily I ahave an unlimited data package but the speeed is really slow ~ 2 Mps.  I have searched the web and see that Apple is saying there is a problem with Exchange server getting too meny messages and thus denying access but have followed the guidance given and reset the phone, resey the wifi connection and no change I can only use the phone on 3G.  I believe there is a big problem here and Apple need to get a fix out pretty quick.  If you read this and have the same issues then please log them so Apple know how big an issue this is.  I know it is not a wifi issue as getting great wifi on my iMAC and wife's iPhone 3.
    regards
    Steve

  • ODBC compatibility problem with server 7.1.5

    Hi all,
    I am suffering from Windows ODBC driver desasters and hope I am not alone with my problem:
    I am developing a client app with Visual Foxpro 5.0a (maybe not relevant to the problem) on Win NT 4.0 SP 6,
    which accesses a Oracle 7.1.5 Server (on Alpha VMS) through ODBC.
    I used for several years the Version 2.0.x of the Oracle ODBC driver with satisfying results.
    Now I have to extent the app to run on Win 95 (sorry, but thats true) and also Win 2000. I am working in a large company
    network and have to take as environment what is provided by the systems group, which is SQL-Net8 and Oracle drivers
    from the 8.x series (8.1.7x for Win 2000 and some 8.0.x for Win 95).
    My problem: While DML commands are just fine with the 8.x drivers on the 7.1 server, I cannot call any stored
    procedures on the driver. I am using "ODBC" syntax, i.e. send strings like
    "{Call Schema1.Package1.ProcedureA(?Variable1, ?@Variable2)}" to the ODBC driver.
    I get the error message "Table/View does not exist", which is garbage, since the same calls work just fine, when
    using the 2.x driver.
    However, with the 2.x drivers, also the procedures get called ok and IN parameters are passed correctly,
    I cannot receive IN OUT parameters! What I get back is what I passed into the procedure plus one arbitrary character.
    Needless to say, that the 8.x drivers work just perfect against an 8i Server. However, I cannot migrate my productive
    database anytime soon.
    Does anybody have an idea which drivers are able to support calling stored procedures on a 7.1.5 server or can point
    me to resources here, which handle the problem?
    Thanks a lot,
    Peter
    PS: Yes I have seen the previous thread stating that, 7.1x servers are no certified for new drivers. But I simply hope, some
    body recognizes my problem and has a solution. :-)

    Thanks for the tip, might well be that this solves my problem (standards always should, or).
    But how do I bind the variables in a separate step the standard way? I never saw that in any docs -neither Foxpro nor VB which of course now moved to ADO.
    Thanks for an example or a pointer to the literature,
    Peter
    The standard ODBC syntax for executing a stored procedure is
    "{Call Schema1.Package1.ProcedureA(?, ?)}"
    The syntax you describe
    "{Call Schema1.Package1.ProcedureA(?Variable1, ?@Variable2)}"
    isn't familiar to me. I assume it's something Microsoft cooked up for pass-through queries (may be something special for FoxPro) that combines a few steps. You may want to try using the standard syntax and doing the variable binding as a separate step.
    I suppose that there might be a problem with the 7.1.5 database and how it handles IN OUT parameters, but that seems unlikely...
    Justin

  • Network Problems with LaCie Firewire or USB Hub

    Hi Folks,
    I have a recurring problem with my 27-Inch iMac mid-2010 running OSX 10.7.2 (had same problem with Snow Leopard before upgrading) where, when a Firewire device ( LA Cie HD) or a USB Hub is pluged-in the wired ethernet will not work on wake up from sleep.
    I always have to cycle off my Cisco Router for the Mac to use the wired ethernet.
    Does not happen with the WIFI and does not happen if there is no firewire device or USB hub pluged in.
    Anyone seen this before? Anyone with an idea on how to resolve this?
    Thanks in advance for your thoughts
    Dan

    I picked up a 2big network a few days ago (to replace two Buffalo LinkStation Pros) and also have not been able to get an icon for the drive to appear on my mac desktop, despite being able to access the 2big through "Connect to Server." I hope to learn more from LaCie.
    A successful workaround I'm using is to put the contents of each share on the 2big drive into a single folder in the share, make an alias of the folder in the share, and drag/copy the alias to the desktop of any machine needing access to the share. Admittedly a little kludgy, but easy to disseminate once set up. The desktop alias calls up the respective folder quite crisply, tested now for several machines on the network -- at least with up to ~40 Gb in a given folder/share so far. For reference, this network currently has 6 Mac and 3 Win XP nodes.

  • Network problem with one particular iMac in a home network

    I want to report a problem involving one particular iMac (2008 Al 24").
    On my home network (Apple Airport Extreme and Express extensions, about five Macs and couple of iDevices), all other Macs can see and connect to each other as well as printing to the networked Brother printer without problem.
    However, on one particular iMac, I can see all other Macs, can set Brother printer as default with green dot next to it in Print Preference Pane, but I can not connect to other macs, nor print to the printer. Meanwhile, the iMac can get on the internet without any problem. I checked Share Preference Pane and all settings are same as other macs.
    The iMac used to work flawlessly until recently, and I first noticed the problem because I could not print, getting a message the printer can not be found (and the dots turn yellow for a while then went back to normal green). Then, I found neither the iMac, nor other macs on the network can connect to each other, even though I can see all of them in Finder.
    I opened Apple Remote Network on my own mac, and I can see and connect all other shared macs, but this iMac's status showed not online, even though the IP adress is valid. As a results, no other macs can connect to the iMac, either. It seems to be a problem with the intranet only, not internet.
    One more thing, about a month ago, the iMac popped out a warning about network name, saying the old name was in use (conflict) in the network, so I have to change it in Share Pane. Not sure if this is related to the intranet problem.
    Reboot and repaired permission several times, no change. Hate to reinstall everything. Any help would be greatly appreciated.

    Another update:
    For unknown reason, my iMac was suddenly back onto the home "intranet". It can be accessed by my MacBook Air through Finder Connect, and can also be seen by Apple Remote Desktop.
    However, printing is still a problem while other macs have no problem printing to the same printer. Whenever I send a print task, either Word document, or other programs such as GraphicConverter image, the iMac tried to connect to the default printer, but failed, and wanted to try again in 30 seconds 9and continued to fail). Meanwhile, the green dot next to the printer selection turned to yellow in Preference Pane. But as soon as I cancel the print job, the printer status went back to normal green.
    The printer is a Brother color laser HL-4070CDW, connected through wireless (g only), with it own DHCP but specific IP address. I printed out a setting for the printer and all looks normal, and all other macs can print to it without problem. Other macs can also get access to the printer profile, and check inks copy counts, etc, but the iMac cannot.
    Only thing changed since last post was a new update for Apple Airport firmware (to 7.5.2 I think). So my problem is still half solved: can connect to other macs on the same network, but still not be able to print.

  • Windows Vista and WiFi networking problem with MackBook Air

    Hi, everyone!
    Thanks in advance for the following help.
    For some specific programms I need Windows Vista to be set up on my MacBook Air.
    The problem with Broadcom WiFi adapter.
    While moving large files over home network it hangs and looses the wifi network. It works OK while surfing the internet or doing other low traffic job. But when it comes to 2 MB/sec transfer it doesn't work. I tried two different routers, no positive result. PC works propely on any file sizes. After booting the Leopard the problem goes away. So it is onle Windows Vista problem.
    May be drivers? I tried 4.170.25.19 Windows Vista drivers from Broadcom - it didn't help. But I am not goog in driver settings in Control Panel, so may be the solution is there.
    Any ideas how to solve it?
    Thanks for help in advance.
    Andrey.

    Hello Nescom. Welcome to the Apple Discussions!
    I'm afraid I really don't have an answer for you but I can offer my experiences with large files transfer with Vista. My current home network is a combination of Windows PC, Windows Servers, and Macs. Large file transfers between most of them have relatively the same performance, except when transferring large files from the Vista PC to any other OS. It is demonstrably slower. Interestingly, transfers between Vista machines does not appear to be a problem. I understand that this is a known problem by Microsoft and was supposed to be fixed with Vista SP1.
    So the problem might not be your network, but Vista itself. I'm curious if you have this problem when transferring large files to another Vista device?

  • Export Release Build - Problem with Server Settings

    Hello, i have a big problem and i searched the whole day yesterday but didnt found an answer...
    I started a Flex Mobile and PHP Project. The Project has a Data/Services included wich loads some customer from a database (sql)... for the first a
    used Zend and try it local (http://localhost and used the htdocs Folder of Zend)... EVERYTHING WORKS PRETTY FINE... so NOW my problem
    I wanted to export this project to a release build for my android phone... so the first warning of Flash Builder ist that the project ist currently configured to access data services from a local url. Before exporting the application, you may need to deploy your services to a remote server, then change the server root URL for your project. Click here to change server settings.
    When i click the button i get the server setting.
    Web root: C:\Program Files (x86)\Zend\Apache2\htdocs
    Root URL: http://localhost
    whe i change it now i get an eror:"The selected web root folder does not exist (i attached i screenshot of it).
    i entered de domain of my server (i also tried the ip) at Root URL. And i think there ist a problem with the Web root...? i get scary

    i know WHY Flashbuilder tells me that i have to change the setting when i deploy on the device
    my problem ist that i got this error...
    and the domain wich i have in the screenshot should only explain how i tried it...
    i entered my server url (the real domain) and i entered the folder "app" wich i have created via ftp on my server...
    BUT i also get this error (lik in the screenshot)
    i think at ROOT URL i cant make lot mistakes .... http://myserver.de or the ip
    but i think maybe my web root ist incorrect? i entered here the folder wich is directliy on my server...?
    i dont know exactly but i got an error like in the screen

Maybe you are looking for

  • Satellite U300-14Q doesn't boot - warranty question

    Hello!! I bought my laptop last may in Spain and today I couldnt boot it. I cant start my computer, so Im really worried about it, because Im going to live in Berlin for 2 months. Can I send my computer to any service center close to Berlin?? Or othe

  • Oracle from DB2 federation - function mapping

    I need to map an Oracle function (instr) from an InfoSphere function (postion) from the DB2 database, so this is more of a DB2 question, but never could get an answer out of DB2ools ;-) I have created the wrapper, server, user mapping and nicknames i

  • Billing ATP Quantities from Order Sales

    Hi, I was wondering if I can generate a billing with the ATP quantities from the sales order without creating the delivery. My problem is that my wholesales want to have a quote of the real stock or his order, so I was thinking to generate a pro form

  • The minimum number of downloads from app store of average paid app ? Describe about guarantee of earning...

    The minimum number of downloads from app store of average paid app ? Describe about guarantee of earning....

  • Bluetooth Stack COM Server Error

    Just got my E66. Gettign repeated "Bluetooth Stack COM Server" errors when my phone is away from the PC. The only thing I can do to re-establish the connection is to reboot the PC. Anyone else have this problem? Any solutions out there? Solved! Go to