Java

Send and Receive Data Using Socket


This blog shows how to send and receive data via TCP/IP using Socket in .NET Framework. There are methods Socket.Send and Socket.Receive.

Socket.Send Method

Send method sends data from your buffer to a connected Socket. When you call the Send method it returns number of bytes which were sent. But it doesn’t mean that the bytes were already received by the other side, it only means that the data were stored in a socket buffer and the socket will be trying to send them. If the socket buffer is full a WouldBlock error occurs. You should wait for a while a try to send the data again. (more…)

How to Parse/read XML file in Java


In this post we will see how to read xml in Java.

Here is the sample XML :

<!--?xml version="1.0"?-->  
<students>  
    <student>  
        <name>John</name>  
        <grade>B</grade>  
        <age>12</age>  
    </student>  
    <student>  
        <name>Mary</name>  
        <grade>A</grade>  
        <age>11</age>  
    </student>  
    <student>  
        <name>Simon</name>  
        <grade>A</grade>  
        <age>18</age>  
    </student>  
</students>

(more…)