Server Socket does not read data input stream

Hi all,
I am very newbie to Java Network programming with sockets and multi-threading.
But I am obliged to develop a chat system written in Applets which can be placed on the website and used by visitors who come to my website.
In order to understand this, I have tested a basic web chat program I downloaded from the Internet which use sockets and multi-threadings. The program work fine, no bugs at all at both compilation and run time. I noticed that all three streams for Client side (i.e. first one is input stream used receiving data from User; the second one is socket input stream used for receiving data from Server socket, and the third is socket output stream used for writing data to server socket) were established. And the same, two socket streams (input & output) for Server side were also connected when running program giving right port number and IP address of the server.
The problem is both server and client sockets do not read data using the following stream classes:
1. DataStreamInput: I use input.readUTF() method
2. or BufferedReader: I use input.readLine() method
The example of the codes are below:
private BufferedReader input = null;
private PrintWriter output = null;
private Socket socket = null;
public void open() throws IOException
{  input = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
System.out.println("Server socket input stream was created, and");
output = new PrintWriter(socket.getOutputStream());
System.out.println("Server socket output stream was created");
public void run()
{  System.out.println("Server Thread " + clientPort + " running.");
while (true)
{  try
System.out.println("Server is reading data from Client, wait...");
String fromClient = input.readLine();
System.out.println("Server received a message on " + clientPort + ".");
catch(IOException ioe)
{  System.out.println(clientPort + " ERROR reading: " + ioe.getMessage());
server.remove(clientPort);
stop();
The problem is at the line: String fromClient = input.readLine(); in the run() method? What is wrong with the codes above?
Note: I also try to use original codes which use readUTF() method in DataStreamInput class instead using readLine() in BufferedReader. Both methods dont read data from inputstream socket?
I very appreciate any help/advice from experienced developers.
Best regards

Hi,
Yes. The readLine() method hangs! After the test, the execuation of the program is stopped at the line of readLine() method; it does not pass it?
There is no problem with writing to Server socket. After the test, the program pass through flush() method. Here is the code for writing to sever socket within ChatClient (client side socket) class:
private BufferedReader input = null;
private PrintWriter           output = null;
public ChatClient(String serverName, int serverPort)
{  System.out.println("Establishing connection. Please wait ...");
try
{  socket = new Socket(serverName, serverPort);
System.out.println("Connected: " + socket);
start();
catch(UnknownHostException uhe)
{  System.out.println("Host unknown: " + uhe.getMessage()); }
catch(IOException ioe)
{  System.out.println("Unexpected exception: " + ioe.getMessage()); }
public void start() throws IOException
{  input   = new BufferedReader (new
                         InputStreamReader(System.in));
System.out.println("Client User input stream was created,");
output = new PrintWriter(socket.getOutputStream());
System.out.println("Client Socket output stream was established, and");
if (thread == null)
{  client = new ChatClientThread(this, socket);
thread = new Thread(this);
thread.start();
public void run()
     while (thread != null) {
     String fromUser;
          try{
               while((fromUser = input.readLine())!= null)
               System.out.println("Client wasreading a data from User, and");
output.println(fromUser);
     output.flush();
     System.out.println("Client has written a data to Server");
catch(IOException ioe)
{  System.out.println("Sending to server error: " + ioe.getMessage());
stop();
etc.
Here is a piece of codes for reading data from the Client Socket in the ChatServer Class (Server Side socket):
public void run()
{  System.out.println("Server Thread " + clientPort + " running.");
while (true)
{  try
{  //server.handle(clientPort, input.readLine());
System.out.println("Server is reading data from Client, wait...");
String fromUser = input.readLine();
//while((fromUser = input.readLine()) != null)
     System.out.println("Server received a message on " + clientPort + ".");
catch(IOException ioe)
{  System.out.println(clientPort + " ERROR reading: " + ioe.getMessage());
server.remove(clientPort);
stop();
etc. Please advice why the readLine() method hangs; does not read data from the input stream received from the CLIENT?

Similar Messages

  • Equium A60 - DVD drive does not read data discs

    Hello
    I am having a problem with my DVD drive on my Toshiba Equium A60 laptop. The DVD drive (Pioneer DVD-RW DVR-K13A ) will play shop bought films etc without a problem. it will also read a blank DVD when you put it in the drive but once information/Data is on the disc it wont detect the disc.
    I am not really that good with computer so any help would be most grateful. The computer used to play everything it just stopped doing it a few months back.
    Many thanks Phil

    The issue is clear.
    Fact is that not all CDs and DVDs are supported and compatible. There could be always an issue with a reading or writing
    The same happened to me too I had to test different CDs and DVDs from different manufacturers and finally some medias worked
    In your user manual you should find a list of medias which were tested and should run properly check it!
    bye

  • Cross tab does not read data after a certain point

    Post Author: tatiana88
    CA Forum: General
    I am using CR10 and have created a simple table that reports hours by month - Jan thru Dec.  The report displays data for the months of Jan thru April, but the data for May and onwards is not being read (it shows as 0 for these months).  I have updated my registry to ensure that the timeout is disabled (value is 0) and that the MaxNBrowseValues is as large enough to cover the numer of records.  The only anomalie is that there is actually a range of records with 0 values exactly at the point where the reporting gets weird, but towards the end, the records in the database actually do have non-zero values, but they are not being picked up by Crystal for some reason.  I would appreciate any help you can offer.

    Post Author: tatiana88
    CA Forum: General
    I have checked the select statement, and there is nothing odd: the date range is a parameter entered selected by the user, and it includes 5/2007 and 6/2007 - and it seems that this range parameter is being taken by Crystal since the columns May and June both appear.  This is strange in that if the values were truly 0 for May and June, the columns themselves would not appear.  Both May and June have data posted in the database.  All other months (Jan through April) show accurately on the Crystal Report.

  • CFGRID does not show data (CF9.0)

    Under development server, CFGRID show data , all is fine , correct. (CF9.0  version dev)
    Under production server , CFGRID does not show data, only a grey line (like a HR).
    How to debug this ?
    Thanks,

    Kindly check below to troubleshoot this issue:-
    Is there any difference between your CF production & developement server setting summary?
    Is there any browser script level difference between your both CF server?
    Are you getting any relevant logging error in your CF server application.log & exception.log?
    Run a very simple cfgrid running app to check, either getting issue with that too or not.

  • Hi, we have a G5 Blade server running OS X 10.5.8 with a dual Fibre Channel card. The OS does not read the card and cannot establish connection to the RAID controller. I have tried to move the card to another port with no luck. Ran all the updated softwar

    Hi, we have a G5 Blade server running OS X 10.5.8 with adual Fibre Channel card. The OS does not read the card and cannot establishconnection to the RAID controller.
    I have tried to move the card to another port with no luck.Ran all the updated software possible. Please can someone advice

    Hi,
    Was the card previously working in that machine? If it was and you have a G5 tower you could try the card in there. Here is a list of Apple fibre cards and cables which show what's compatible with what. http://support.apple.com/kb/HT1769
    The card should appear in the System Profiler under Fibre Channel and PCI Cards.
    All the best
    Beatle

  • GUI_UPLOAD NOT READING DATA FROM PRESENTATION SERVER

    H HI IN   MY APPLICATION I HAVE USED GUI _UPLOAD        TO READ DATA FROM   PRESENTATION SERVER   IT WAS WORKING FINE BUT NOW I HAVE SCHEDULED IT IN BACK BACKGROUND WHEN I   DEBUGGED IT GUI _UPLOADI NOT READING DATA FROM PRESENTATION SERVER
    Edited by: ravikumar1006 on Mar 10, 2012 1:18 PM
    Moderator message: FAQ, please search before posting, do not write in all upper case.
    Edited by: Thomas Zloch on Mar 10, 2012 3:17 PM

    The issue is that, when you schedule a program as background job runs on application server not on local pc for that program use the application server resurces  and its not possible to read files from pc. You can find a lot of answers in forum for this

  • Error while executing SSIS package - Error: 4014, Severity:20, State: 11. A fatal error occurred while reading the input stream from the network. The session will be terminated (input error: 109, output error: 0)

    Hi,
    We are getting the following error when running our SSIS packages on Microsoft SQL Server 2012 R2 on Windows Server 2008 R2 SP1:
    Error: 4014, Severity:20, State: 11.   A fatal error occurred while reading the input stream from the network. The session will be terminated (input error: 109, output error: 0)
    SQL Server Data Tools and SQL Server Database Engine reside on the same server.
    We tried the following:
    Disabling TCP Chimney Offload
    Installed Windows Server 2008 SP1
    Splitting our SSIS code into multiple steps so it is not all one large continuous operation
    The error occurs during a BulkDataLoad task.
    Other options we are investigating with the engineering team (out-sourced, so delayed responses):
    Firewall configurations (everything is local, so this should not make a difference)
    Disabling the anti-virus scanner
    Are there other things we can try?
    Any insight is greatly appreciated.
    Thanks!

    Hi HenryKwan,
    Based on the current information, the issue can be caused by many reasons. Please refer to the following tips:
    Install the latest hotfix based on your SQL Server version. Ps: there is no SQL Server 2012 R2 version.
    Change the MaxConcurrentExecutables property from -1 to another one based on the MAXDOP. For example, 8.
    Set "RetainSameConnection" Property to FALSE on the all the connection managers.
    Reference:
    https://connect.microsoft.com/SQLServer/feedback/details/774370/ssis-packages-abort-with-unexpected-termination-message
    If the issue is still existed, as Jakub suggested, please provide us more information about this issue.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Adobe form created in LiveCycle does not remember user input

    Adobe form created in LiveCycle does not remember user input when the file has been re-opened after it has been saved.
    Example:
    "Check box" that has been selected and who have registered Action script (may be that it should be disabled), seems to be reset when the file is re-opened, although it apparently is checked.
    Are there settings or script that can prevent this?

    Hi there,
    usually if the values are not kept in form after saving and re-opening the form, it would be because of your code... or because it is not Reader Extended PDF...
    If your code has a function which is to return a value to your field without it to be working based on your Design, it will reset any data..(variables)
    Which means...
    e.g.: You have an array/var/JSONobject which you populate varying on the data entered in the design, as long as you are in the actual form, without closing and re-opening the form, it will keep all values inside that array / variables / JSONobject. But, once the form closed and re-opened, if you have a function that returns a value to your field, whatever the field, from any variable in the script it will return nothing because every variables are reset. To avoid such a thing, you must repopulate all variables that were assigned previously before closing the PDF Form. To do so, I recommend to have a page(hidden) which contains every important values according to that function and you must repopulate those variables according to the values in the keepVar page...
    If you do not have any function that returns a value to a field based on your variables, this is not the solution you are looking for and I am not aware of the reason why it behaves like this... Maybe more information on the behaviour of your form would help locate the issue...
    Hope this help

  • System keeps looking for a 'server' that does not exist. Is says the old name of my Airport Extreme. Clicking it away (4x) it gets through.

    System keeps looking for a 'server' that does not exist. Is says the old name of my Airport Extreme. Clicking it away (4x) finally  gets through.

    Other weirdness to report: my neighbor upstairs appears to have a Linksys router network on channel 6. My AEBS is on channel 1 so there shouldn't be interference... but according to iStumbler sometimes the signal leaps to 64000 (keep in mind my own Airport never tops 60)! Is that potentially the problem?
    Might it be possible that your neighbor just acquired a 802.11n (pre-N) wireless router recently?
    802.11n effectively increases capacity by doubling the number of Wi-Fi radios and increasing the number of antennas used to push signals out of those radios. 802.11n splits a data frame into multiple pieces. It then transmits these pieces in parallel using multiple radios that are attached to multiple antennas. These antennas blast out signals from virtually the same vantage point – scattering the signals everywhere.
    You may find the following ZDNet article interesting: http://blogs.zdnet.com/Ou/?p=247
    Even if he did not, and you are on good terms, you might want to ask if he can temporarily turn off his wireless, or, at least, reduce the signal strength to see if that will help in your situation.

  • Aperture was not able to adjust the date and time of the master file "2008-06-22 at 14-41-14.jpg" because it has a format that does not permit date modification.

    I can't seem to find a way to update the date/time of a master file. There is a format issue but I can't seem to figure out how to correct it.
    Aperture was not able to adjust the date and time of the master file “2008-06-22 at 14-41-14.jpg” because it has a format that does not permit date modification.

    Can you post an ipconfig /all from the server and the DC?
    Robert Pearman SBS MVP
    itauthority.co.uk |
    Title(Required)
    Facebook |
    Twitter |
    Linked in |
    Google+

  • WD ALV: Image in server cache does not appear in Excel

    Hello WD Experts!
    I have a Web Dynpo ALV table with material master data. One column contains the image of the product or a "sorry, no picture" image, if no specific material image exists.
    The images are not available as MIME objects, hence I load the images from an external source and push them into the server cache using the method cl_http_server=>server_cache_upload( ... ). The lifetime for the cache is defined with 600. The "sorry, no picture" -image is a MIME object.
    All works fine... except for the download to Excel. Only the "sorry, no picture" -image appears. The others gets replaced by a placeholder icon which looks similar to those frequently seen in emails or slow web pages.
    Why don't the cached images get downloaded to Excel???
    Best Regards
    Bodo

    Has to be programmed manually because WD ALV does not read from server cache

  • OLE DB provider "Microsoft.ACE.OLEDB.15.0" for linked server "(null)" does not support the required transaction interface

    Hi All,
    I am trying to execute a stored procedure and store its result in an excel.
    My query to execute stored proc and store sresults in excel
    INSERT INTO
    openrowset('Microsoft.ACE.OLEDB.15.0',
    'Excel 8.0;Database=C:\TC\DataAnalysisFiles\DataAnalysisResult.xls;OLE DB Services=-4','select * from [Sheet1$]')
    EXEC UspUnitTest_Test_CheckDuplicateModelNumberSerialNumber
    I am getting error
    The requested operation could not be performed because OLE DB provider "Microsoft.ACE.OLEDB.15.0" for linked server "(null)" does not support the required transaction interface.
    I have enabled below things by running scripts
    sp_configure 'show advanced options', 1;
    GO
    RECONFIGURE;
    GO
    sp_configure 'Ad Hoc Distributed Queries', 1;
    GO
    RECONFIGURE;
    GO
    EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.15.0', N'AllowInProcess', 1
     GO
     EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.15.0', N'DynamicParameters', 1
     GO
    Please help and let me know if this can be resolved
    Supriya Thigale

    because OLE DB provider "Microsoft.ACE.OLEDB.15.0" for linked server "(null)" does not support the
    required transaction interface.
    Hello,
    When you insert data from SQL Server into a linked server, then a distributed transaction should be started and here it seems this fails.
    See
    Distributed Transactions (Database Engine) for more Details +
    Distributed Queries
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Getting error 462 - The remote server machine does not exist or is unavailable

    I have several modules that read and write data to and from Excel 2010 worksheets. I am noticing that the Excel process does not end aven though Excel is not running on my PC. It is like an orphan process. If I try running the Access module again I get the
    message "error 462 - The remote server machine does not exist or is unavailable". Here is the code I am running. When I click the Debug button on the message box the line "rowNum = objXLAppln.Range("A" & Rows.Count).End(xlUp).Row"
    is highlighted.
    Option Compare Database
    Option Explicit
    Function ImportImportanceScores()
    Dim RecSet As DAO.Recordset
    Dim objXLAppln As Excel.Application
    Set objXLAppln = New Excel.Application
    Dim objWBook As Excel.Workbook
    Dim rowNum As Variant
    Dim i As Integer
    Dim j As Integer
    Dim StrPathFile As String, strFile As String, strPath As String
    Dim strBrowseMsg As String, strInitialDirectory As String, strFilter As String
    'show dialogue box
    strBrowseMsg = "Select the EXCEL file:"
    'set directory to load files from
    strInitialDirectory = "C:\Bridge_CIP_Part-A_B\"
    'run strFilter function
    strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xlsx)", "*.xlsx")
    StrPathFile = ahtCommonFileOpenSave(InitialDir:=strInitialDirectory, _
    Filter:=strFilter, OpenFile:=True, _
    DialogTitle:=strBrowseMsg, _
    Flags:=ahtOFN_HIDEREADONLY)
    If StrPathFile = "" Then
    MsgBox "No file was selected.", vbOK, "No Selection"
    Exit Function
    End If
    'Set Excel application object. Critical for macro to run properly. Do not change.
    'Open workbook and worksheet to load data.
    With objXLAppln
    Set objWBook = objXLAppln.Workbooks.Open(StrPathFile)
    objXLAppln.Visible = True
    End With
    Set RecSet = CurrentDb.OpenRecordset("Importance_Scores")
    'Copy data from Excel cells to Access fields
    objXLAppln.Sheets("Importance_Scores").Select
    rowNum = objXLAppln.Range("A" & Rows.Count).End(xlUp).Row
    objXLAppln.Range("A6").Select
    'Add records to table from Excel
    With RecSet
    For i = 0 To rowNum - 6
    RecSet.AddNew
    RecSet.Fields("CIP_ID").value = objXLAppln.ActiveCell.Offset(i, 0).value
    RecSet.Fields("Target_Timeframe_for_Construction").value = objXLAppln.ActiveCell.Offset(i, 2).value
    RecSet.Fields("ImportanceFactor_TI-1").value = objXLAppln.ActiveCell.Offset(i, 21).value
    RecSet.Fields("ImportanceFactor_TI-2").value = objXLAppln.ActiveCell.Offset(i, 22).value
    RecSet.Fields("ImportanceFactor_TI-3").value = objXLAppln.ActiveCell.Offset(i, 23).value
    RecSet.Fields("ImportanceFactor_TI-4").value = objXLAppln.ActiveCell.Offset(i, 24).value
    RecSet.Fields("ProjectRank").value = objXLAppln.ActiveCell.Offset(i, 33).value
    RecSet.Update
    Next i
    End With
    'Close everything
    RecSet.Close
    objWBook.Close SaveChanges:=False
    objXLAppln.Quit
    Set RecSet = Nothing
    Set objWBook = Nothing
    Set objXLAppln = Nothing
    End Function

    In the line
        rowNum = objXLAppln.Range("A" & Rows.Count).End(xlUp).Row
    Rows does not refer to objXLAppln or to objWBook. Change it to
        rowNum = objXLAppln.Range("A" & objWBook.Sheets("Importance_Scores").Rows.Count).End(xlUp).Row
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Lsmw recording does not read Scroll down

    Hi expers.
    This is not MM RElated question but there are more experts here..You may help us
    WE have mass data to introduce by VK11.WE want to use LSMW recording.
    But the problem;
    We input condition type,then we have to select key combination.But we have to scroll down to click key combination.And lsmw does not read sroll down and select the first key combination instead of ours.
    İs the any solution to solve tihis problem..
    Thanks in advance..

    Your BDC in lsmw will look something like this...
                                                  T   VK11     BS AA X   F
    SAPMV13A     0100     X                                                                               
    BDC_CURSOR      RV13A-KSCHL
                                                      BDC_OKCODE      =ANTA
                                                      RV13A-KSCHL      ZCON
    SAPLV14A     0100        X                                                                               
    BDC_CURSOR           RV130-SELKZ(03)
                                                      BDC_OKCODE       =WEIT
                                                      RV130-SELKZ(01)
                                                      RV130-SELKZ(03)      X          <<<<Change this number to the row number of the key combination
    You see the 03, it will put the radio button at row 3, if yours is 9, make it 09 and see.
    Edited by: Jeevan Sagar on Feb 3, 2012 6:01 PM

  • I have a brandnew 7th gen classic ipad, it does not read in my itunes anymore. i bought it cause apple was suppose to be good, now i am lost as i just want my music, any help. tried the rec. steps to fix it and nothing

    let em elaborate more, the unit is less than 5months old, i bought it just for music, i use to have a lot of cds, well it does not read anynore in my computer nor the itunes programe, i reset it, i put it to disk mode, i down loaded the newest itunes program, i want to know how to fix this as i paid apple good money for a product that died after 5months, for real.
    this is bad business and i need some help

    Does the iPod work okay otherwise apart from not being able to connect with and communicate with iTunes?
    Have you tried connecting the iPod to another PC or Mac running iTunes to see if it is properly recognized there?
    Is iTunes up to date on your PC?  Does it appear in Device Manager when you plug it in? To access Device Manager, click start, right->click on Computer (or My Computer in Windows XP) and choose Manage.  When the window opens, select Device Manager in the left hand pane if necessary.
    Any unknown devices listed or does the iPod appear anywhere under USB Host Controllers?
    B-rock

Maybe you are looking for