Learning Network Programming with Java

Learning Network Programming with Java

Key Features
  • Learn to deliver superior server-to-server communication through the networking channels
  • Gain expertise of the networking features of your own applications to support various network architectures such as client/server and peer-to-peer
  • Explore the issues that impact scalability, affect security, and allow applications to work in a heterogeneous environment
Book Description
Network-aware applications are becoming more prevalent and play an ever-increasing role in the world today. Connecting and using an Internet-based service is a frequent requirement for many applications. Java provides numerous classes that have evolved over the years to meet evolving network needs. These range from low-level socket and IP-based approaches to those encapsulated in software services.

This book explores how Java supports networks, starting with the basics and then advancing to more complex topics. An overview of each relevant network technology is presented followed by detailed examples of how to use Java to support these technologies.

We start with the basics of networking and then explore how Java supports the development of client/server and peer-to-peer applications. The NIO packages are examined as well as multitasking and how network applications can address practical issues such as security.

A discussion on networking concepts will put many network issues into perspective and let you focus on the appropriate technology for the problem at hand. The examples used will provide a good starting point to develop similar capabilities for many of your network needs.

What you will learn
  • Connect to other applications using sockets
  • Use channels and buffers to enhance communication between applications
  • Access network services and develop client/server applications
  • Explore the critical elements of peer-to-peer applications and current technologies available
  • Use UDP to perform multicasting
  • Address scalability through the use of core and advanced threading techniques
  • Incorporate techniques into an application to make it more secure
  • Configure and address interoperability issues to enable your applications to work in a heterogeneous environment
About the Author
Richard M Reese has worked in both industry and academia. For 17 years, he worked in the telephone and aerospace industries, serving in several capacities, including research and development, software development, supervision, and training. He currently teaches at Tarleton State University, where he has the opportunity to apply his years of industry experience to enhance his teaching.

Richard has written several Java books and a C Pointer book. He uses a concise and easy-to-follow approach to topics at hand. His Java books have addressed EJB 3.1, updates to Java 7 and 8, certification, functional programming, jMonkeyEngine, and natural language processing.

Table of Contents
  1. Getting Started with Network Programming
  2. Network Addressing
  3. NIO Support for Networking
  4. Client/Server Development
  5. Peer-to-Peer Networks
  6. UDP and Multicasting
  7. Network Scalability
  8. Network Security
  9. Network Interoperability


Read More..

Random number generator in c programming

This tutorial contains
  • How to generate a random number using rand()
  • Simple example using rand() function
  • Generate random number in a specific range dice example

To generate a random number in c++ program first we have to include a header file which is
#include<cstdlib> because we have to use a function from that library which is “rand();” this functions simple returns a random number

Let use that function

#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
  cout<<rand()<<endl;
return 0;
}


It will return a random number for example
41
 Let use a loop and generate some more random numbers using that function

#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
 for(int i=1;i<=10;i++)
    cout<<rand()<<endl;
return 0;
}

It will generate 10 random  numbers
What if we want to generate random numbers with in the specific range like we want to generate random numbers between 1 to 10 or 50 to 100

for example range is 1 to 10

We think something like that cout<<rand()%10;

How it will work
It will take a random number divide it by 10 and return us the number the number can be from 0 to 9
After getting the output we see that if we add 1 in the result value we can get our required range values
So we will change it like that << 1 + ( rand() % 10 ) ;

Lets take another example of a dice it can generate numbers 1 to 6 randomly

 we will simple something like that
But is it write or not


for(int i=1;i<=6;i++)

    cout<< rand()%6<<endl;


And there is a problem it will return us number from 0 to 5 to make the logic of our program we will change it like that
for(int i=1;i<=6;i++)

    cout<< 1+ (rand()%6)<<endl;

So this will work fine in this case 0 is eliminate and whatever number will return 1 will be added in it like if 0 is generated it will result as 1 if 5 is generated it will return us 6
  
Hope this tutorial will help to understand the basic about of random number
Read More..

Increase your Programming Skills II

This is the continuation of the last article… Increase
your Programming Skills


Solve the problems listed here to gain programming skills.


Problem #5:


  // Problem or Question in C++
// --------------------------
// Problem related to pointers
// for increasing programming
// skills

#include<iostream.h>

void main()
{
char ch1[]="Programming";
char ch2[]="Skills";

char *s1=ch1;
char *s2=ch2;

while(*s1++=*s2++);
cout<<ch1;
}

Problem #6:


  // Problem or Question in C++
// --------------------------
// Problem related to pointers
// for increasing programming
// skills

#include<iostream.h>

void main()
{
int i, *j;

i=1;
j=&i;

cout<<i**j*i+*j;
}

Problem #7:


  // Problem related to pointers

#include<iostream.h>

void main()
{
int ar[]={1,2,3,4,5};
char *p;

p=(char *)ar;

cout<<*((int *)p+3);
}

Problem #8:


  // Problem related to pointers

#include<iostream.h>

void change(int *,int);

void main()
{
int ar[]={1,2,3,4,5};

change(ar,5);

for(int i=0;i<5;i++)
cout<<*(ar+i);
}

void change(int *p,int n)
{
for(int i=0;i<n;i++)
*(p+i)=*(p+i)+3;
}

ANSWERS:


#5: Skills


#6: 2


#7: 4


#8: 45678


Good-Bye!


Related Articles:


Read More..

Blog Archive

Powered by Blogger.