Re: NullPointerException in Socket

Thomas Chenot <tom.chenot-6tN4nzCoH/[email protected]>
Newsgroups gmane.comp.hardware.microcontrollers.tini
Message-ID <[email protected]>
The scope of your listenSocket below is the enclosing try/catch block.

You are assigning a ServerSocket to one local object and attempting to 
use the accept() method in another object.

Denis Yakovlev wrote:

>Hi,Shawn!!!
>Thank you very much for your answer.
>But I didn`t forget create ServerSocket at the begin of the programm.
>try{
>  
>
// BEGIN_SCOPE

>     ServerSocket listenSocket= new ServerSocket(SERVER_PORT);
>  
>
//^^^^^^_^^^^^^^^^^_ local ServerSocket created here

>     System.out.println("Socket is cool!");
>  
>
// END_SCOPE

>        }
>        catch (IOException excp)
>        {
>        System.err.println("Unable to listen port" + SERVER_PORT + ":" +excp);
>        }
>When I run this programm I see - "Socket is cool", but then at point described 
>above I have NullPointerException.
>Have you more ideas?
>Excuse me ,but I need any help.
>
>Thanks a lot.
>
>В сообщении от Понедельник 03 Май 2004 21:29 вы написали:
>  
>
>>Hi, Dennis.  It looks like you've forgotten to create the ServerSocket
>>object:
>>
>>	listenSocket = new ServerSocket(some_port);
>>
>>Regards,
>>	-Shawn
>>
>>On 3-May-04, at 5:46 AM, Denis Yakovlev wrote:
>>    
>>
>>>Hi, All!
>>>Can you help me with folowed problem? May be I just have poor
>>>knowledge in
>>>Java. So...
>>>The problem:
>>> public ServerSocket listenSocket ;
>>>
>>>public void serveTini() {
>>>         Socket clientSocket;
>>>                try{
>>>                        System.out.println("Point1");
>>>                        while(keepRunning){
>>>                                System.out.println("DeadPoint");
>>>                                 clientSocket = listenSocket.accept();
>>><----
>>>
>>> at this point I have an error:
>>>
>>>java.lang.NullPointerException
>>>   in SockTiniTerm.serveTini(@JPC=b0010)
>>>      in java.lang.System.???
>>>
>>>What should I do? Is syntax correct? Anybody please help me
>>>
>>>
>>>
>>>--
>>>Best regards
>>>Denis Yakovlev,
>>>      
>>>
>
>  
>


-- 
Thomas Chenot

_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.