LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-19-2009, 10:34 AM   #1
akromyk
LQ Newbie
 
Registered: Nov 2009
Posts: 5

Rep: Reputation: 0
Need a starting point. I want to create my own network program for multiple OSes


I need help find a starting point as to go about this.

I have some novice to intermidiate progamming skills from a past life. What I want to do is create a program and run it on two seperate computers to just get them communicating together over the network on a basic level. I would like to do this in a language that doesn't limit me to a specific OS, this way I can have a linux and windows computer talking. However, I would prefer a language that can be useful down the road as well. My second inspiration, next to networking, is web design and web programming, which I hope to dig into as well eventually.

I'm not aiming to do anything overtly-complicated. One example that comes to mind would be a program that forwards any typed characters on one computer over the network and displays them on the other, and vice-versa.

I guess the program would run over TCP/IP. However, it would be nice to learn how to do this in a language that not only works on multiple OSes, but also has the ability to allow me to program my own communication protocol, aside from TCP/IP, down the road.

My intention with all this is to learn some network programming for fun.

I don't have to know everything.Any help at all is appreciated.

Last edited by akromyk; 11-19-2009 at 10:57 AM.
 
Old 11-19-2009, 12:15 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by akromyk View Post
I need help find a starting point as to go about this.

I have some novice to intermidiate progamming skills from a past life. What I want to do is create a program and run it on two seperate computers to just get them communicating together over the network on a basic level. I would like to do this in a language that doesn't limit me to a specific OS, this way I can have a linux and windows computer talking. However, I would prefer a language that can be useful down the road as well. My second inspiration, next to networking, is web design and web programming, which I hope to dig into as well eventually.

I'm not aiming to do anything overtly-complicated. One example that comes to mind would be a program that forwards any typed characters on one computer over the network and displays them on the other, and vice-versa.

I guess the program would run over TCP/IP. However, it would be nice to learn how to do this in a language that not only works on multiple OSes, but also has the ability to allow me to program my own communication protocol, aside from TCP/IP, down the road.

My intention with all this is to learn some network programming for fun.

I don't have to know everything.Any help at all is appreciated.
C and C++ are the most common ones to use. Work fine on Linux, Mac, and windows, along with others (BSD, BeOS, etc.).
 
Old 11-19-2009, 12:18 PM   #3
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
Quote:
Originally Posted by TB0ne View Post
C and C++ are the most common ones to use. Work fine on Linux, Mac, and windows, along with others (BSD, BeOS, etc.).
Java - write once, run anywhere Also, it's very easy for network programming
 
Old 11-19-2009, 12:34 PM   #4
akromyk
LQ Newbie
 
Registered: Nov 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks. Does anyone know of any good network programming tutorials or books with a lot of hand-holding for beginners like me?
 
Old 11-19-2009, 12:39 PM   #5
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
Quote:
Originally Posted by akromyk View Post
Thanks. Does anyone know of any good network programming tutorials or books with a lot of hand-holding for beginners like me?
Well the great thing about Java is that the entire API documentation is available online at the sun website and includes a whole load of tutorials, as well as a forum where you can ask other java programmers for help.

http://java.sun.com
http://java.sun.com/new2java/
http://java.sun.com/developer/onlineTraining/index.jsp
http://java.sun.com/docs/books/tutorial/index.html
 
Old 11-19-2009, 01:00 PM   #6
akromyk
LQ Newbie
 
Registered: Nov 2009
Posts: 5

Original Poster
Rep: Reputation: 0
If I were to learn network programming using either of these language, how closely will those techniques transfer over to the other language? For example, if I learn how to open and close connections, and transfer data over the network, is it pretty easy to do it the same in the other language? Or is it a totally different beast in each?

One thing that just popped into my head is PHP. How well can that do network programming and how does it's technique compare to that of Java or C/C++? The reason why I ask is because I have access to my website here from work, so I actually upload some code to it while I'm here. I always looked at PHP as being nothing more than a server-side language. How can it be used for network programming in that case?
 
Old 11-19-2009, 01:18 PM   #7
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
Quote:
Originally Posted by akromyk View Post
If I were to learn network programming using either of these language, how closely will those techniques transfer over to the other language? For example, if I learn how to open and close connections, and transfer data over the network, is it pretty easy to do it the same in the other language? Or is it a totally different beast in each?

One thing that just popped into my head is PHP. How well can that do network programming and how does it's technique compare to that of Java or C/C++? The reason why I ask is because I have access to my website here from work, so I actually upload some code to it while I'm here. I always looked at PHP as being nothing more than a server-side language. How can it be used for network programming in that case?
Not all that familiar with PHP outside of the scope of webpages, sorry.

As for the other part... it's hard to explain! The actual process of establishing a connection or listening for an incoming connection on a socket, sending or receiving data and acting on it is similar in as much as you do the same thing in both languages. What differs is the WAY you do those things. I'm not sure that makes any sense.

I guess what I mean is you program's flow control would look the same in either language, but you would use different classes and methods to achieve your goal. However, in both cases you would set up some sort of listening socket, you'd receive data on that socket and you'd process it (or for the sending computer, you'd open a connection to a socket at a host and write data to that socket).

I don't think I've explained myself well.

In Java creating a socket and writing data is as simple as:
Code:
Socket s = new Socket("host.name.com", 6969);
DataOutputStream os = new DataOutputStream(s.getOutputStream());
s.write("write some data");
and on the host machine you'd similarly set up a ServerSocket object to listen for incoming connections and maybe poll for incoming data every so often.

Last edited by Komakino; 11-19-2009 at 01:26 PM.
 
Old 11-19-2009, 01:48 PM   #8
akromyk
LQ Newbie
 
Registered: Nov 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks, I get what your saying.

So is there any big limitations in performance or capabilities in choosing java over c/c++? For example, could I create a java firewall program that blocks particular ports and forwards the rest of the connections out another nic? Could I also create a proxy using java and have it filter certain urls before forwarding the rest out a second a nic? Basically, run a program on an extra computer with two network cards to create my own proxy and firewall? If java is capable, is there any big disadvantages with taking the java route to doing this?

Last edited by akromyk; 11-19-2009 at 01:52 PM.
 
Old 11-19-2009, 02:20 PM   #9
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
Quote:
Originally Posted by akromyk View Post
Thanks, I get what your saying.

So is there any big limitations in performance or capabilities in choosing java over c/c++? For example, could I create a java firewall program that blocks particular ports and forwards the rest of the connections out another nic? Could I also create a proxy using java and have it filter certain urls before forwarding the rest out a second a nic? Basically, run a program on an extra computer with two network cards to create my own proxy and firewall? If java is capable, is there any big disadvantages with taking the java route to doing this?
It's a toss up, really. C++ has better performance than Java, but actually these days the old "Java is sloooowwww" thing is really a myth. The latest JVM is starting to really get close to C++ where performance is concerned. C (not C++) is still the fastest, but then suffers from being much harder to get going in the first place (I had to buy a book to even start socket programming in C).

On the other hand Java does make the task quite easy because there are existing classes for virtually everything you'd need to do.

Perhaps it would be an idea for you to start by researching a bit of each language? Maybe search for "socket programming in C++" and "socket programming in Java" and see what you think.
 
Old 11-19-2009, 02:28 PM   #10
akromyk
LQ Newbie
 
Registered: Nov 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Sounds like a good idea. My main goal is to have fun while gaining a better understanding of how the lower levels of a network operate, but I'm not gonna have fun if I can't get my computer to talk with another; would it be worth looking into a "socket programming in C" book or does that sort of thing get way too complicated?

Last edited by akromyk; 11-19-2009 at 02:31 PM.
 
Old 11-21-2009, 01:33 AM   #11
gzunk
Member
 
Registered: Sep 2006
Posts: 89

Rep: Reputation: 20
If your requirement is to have fun while learning, then I would definitely recommend doing Java first - because as has been said it does provide a lot of help for things that you might want to do.

Once you've got that mastered, then I would get a socket programming in C book, so that you can see "how the other side" do it. There's nothing like comparing two ways of doing things to really learn about a subject.

Then you can try writing a network server in one language, and the client in the other and explore the wonders of interoperability!
 
Old 11-21-2009, 01:40 PM   #12
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
Quote:
Originally Posted by akromyk View Post
Sounds like a good idea. My main goal is to have fun while gaining a better understanding of how the lower levels of a network operate, but I'm not gonna have fun if I can't get my computer to talk with another; would it be worth looking into a "socket programming in C" book or does that sort of thing get way too complicated?
Unless you're actually planning on learning C I wouldn't bother. C++ maybe, but not C.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
grub2 - multiple OSes milomak Linux - General 7 06-17-2009 07:51 PM
[SOLVED] Trying to fix boot loader with multiple OSes 81bones Linux - Hardware 7 02-02-2009 06:45 PM
Multiple OSes Millenniumman Linux - General 25 09-05-2008 12:01 PM
Complicated Network Setup- Need a starting point nhouseman85 Linux - Networking 3 09-15-2006 01:40 AM
Sharing printers over multiple OSes mopron Linux - General 0 05-07-2002 09:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration