Network Programming

I am somewhat familiar with how to make a connection between two machines and have one application talk to another. Basically you have a ServerSocket that the server uses to "listen: for incoming connections and a Socket that a client uses in order to initiate a connetion. Once a client makes a socket connection, the ServerSocket reutrns (via accept() ) a corresponding Socket through which communication takes place. You then have a true Socket to Socket connection and are able to treat the connection as an simple I/O Stream.
But how would I be able to simply establish a connection between a Java Application on one machine and a C application on the other. I am not that familiar with C code...but I need to be able to send strings from my Java application into an application that a team member of mine is writing.

On the java side you use the same Socket and ServerSocket code. On the C side it really depends on which C you are using and which operating system. In VC++ version 5 or 6 you should look at the MS WSA* functions or you could use the socket implementation in MFC. If you using Ansi C on a unix or linux system you can use "berkeley sockets", to get a start check out "man socket".
You might want to get a copy of "Unix Network Programming Volume 1" by Stevens, regardless of the C system you plan to use.
http://www.amazon.com/exec/obidos/tg/detail/-/013490012X/104-8001926-7743921?v=glance

Similar Messages

  • Network Programming exam papers (college exam papers)

    hello.
    my name is james mcfadden and i am a final year (4th year) undergraduate computing student at Letterkenny Institute of Technology. my e-mail address is [email protected] I have a question here for you. Would you have links to online versions of final year undergraduate Computing exam papers, specifically Networked Applications Development and or Network Management exam papers? I was only able to get access to Trinity College Dublin�s exam papers and Letterkenny IT�s exam papers.
    The 2005/06 academic year is the 1st academic year that final year undergraduate computing students at Letterkenny IT are being taught how to continue doing network programming in Java. i was taught how to do simple network programs in Java when I was in 3rd year.
    The name of the network programming subject that I�m doing in 4th year is Network Programming for Broadband Systems. It is divided into 2 parts: Programming and Networks. In past exam papers (C++ papers), a student would have had to answer 4 out of 6 questions. There would�ve been 4 programming questions and 2 networking questions on those papers. It is going to be the same for both the Summer and Autumn 2007 Broadband Network Programming exam papers, apart from fact that they will be Java papers and that a lot of the material that I have learned is new.
    In 4th year I did Multicast Sockets, Threads, Non-Blocking I/O, Remote Method Invocation, Protocol Handlers, and Content Handlers for the Programming part of the subject (Java Network Programming, 3rd Edition, by Elliote Rusty Harold).
    I did Network Security and Network Management for the Networks part of the subject (Computer Networking : A Top-Down Approach Featuring The Internet, 3rd Edition, by James F. Kurose and Keith W. Ross).
    Your help is greatly appreciated.
    Thank you.

    I have a question here for you.
    Would you have links to online versions of final year
    undergraduate Computing exam papers, specifically
    Networked Applications Development and or Network
    Management exam papers? No

  • How to write JDBC code in a java thread? for network programming

    Hii guys, i am new to java network programming. I developed small swing application for stock controlling in a shop, so i need to run the database in a server. i try the peer to peer scenario, but the response is too late and the application get stuck. there i wl put my data base java class
    please help me for this, how can i change this java class to networked JDBC
    import com.mysql.jdbc.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.Statement;
    public class ConnectionSet {
    private String severIp = "localhost";
    private String severPort = "3306";
    private String userName = "root";
    private String password = "123";
    private ResultSet rs;
    public void setSeverIp(String Ip) {
    severIp = Ip;
    public void setSeverPort(String Port) {
    severPort = Port;
    public void SetUserName(String Name) {
    userName = Name;
    public void setPassword(String passWord) {
    password = passWord;
    public ResultSet getResult(String url) throws Exception {
    Class.forName("com.mysql.jdbc.Driver");
    Connection cc = (Connection) DriverManager.getConnection("jdbc:mysql://" + getSeverIp() + ":" + getSeverPort() + "/suriyalanka", getUserName(), getPassword());
    Statement s = cc.createStatement();
    rs = s.executeQuery(url);
    // java.sql.ResultSet rs = (ResultSet) DriverManager.getConnection("jdbc:mysql://"+getSeverIp()+":"+getSeverPort()+"/suriyalanka",getUserName(), getPassword()).createStatement().executeQuery(url);
    return rs;
    public Connection getConnection() throws Exception {
    Class.forName("com.mysql.jdbc.Driver");
    Connection cc = (Connection) DriverManager.getConnection("jdbc:mysql://" + getSeverIp() + ":" + getSeverPort() + "/suriyalanka", getUserName(), getPassword());
    return cc;
    public void setResult(String url) throws Exception {
    Class.forName("com.mysql.jdbc.Driver");
    Connection cc = (Connection) DriverManager.getConnection("jdbc:mysql://" + getSeverIp() + ":" + getSeverPort() + "/suriyalanka", getUserName(), getPassword());
    Statement s = (Statement) cc.createStatement();
    s.executeUpdate(url);
    public String getSeverIp() {
    return severIp;
    public String getSeverPort() {
    return severPort;
    public String getUserName() {
    return userName;
    public String getPassword() {
    return password;
    please help me for this, how can i change this java class to networked JDBC
    Edited by: 798670 on Sep 29, 2010 6:04 AM

    Have you verified that your mysql allows network connections?
    In order to allow network connections you have to comment or remove line "skip-networking" in my.ini(windows) or my.cnf(unix) configuration files of your mysql instance.
    Or if you have the mysql administrator installed
    MySQL Administrator / Startup Variables / Disable networking (uncheck)
    By!

  • Where can I find knowledge about "java network programming"?

    I am interested in network programming in java. I need some documents and I don't where can I find it?

    http://java.sun.com/docs/books/tutorial/networking/index.html

  • Network programming beginner

    Hi All,
    I have been programming for a while in java but for the first time am doing network programming. Basically I have to connect to one of our supplier's systems. They have setup a raw TCP/IP exchange for request response. We send them requests as a string over tcp/ip and they reply back with a string. The formats of course are propritory to the supplier(a big telecom company).
    My problem is quite simple at the surface, i the hell cant figure this out!!
    We have mulitple suppliers and I have a method called sendRequest(String req) in a general SupplierConnect interface. The implementation for this supplier (other suppliers talk SOAP so its simpler :) ) opens a socket... my code is as follows
    +++++++++++++++++++++++++++++++++++++++++++++++++
    public String sendRequest(String requestData) throws Exception{
    Socket sock = new Socket("xx.xxx.xxx.xx", 15001);
    StringBuffer responseData = new StringBuffer();
    try{
    //     sock.setSoTimeout(15000);     
    //setup writer
    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));
    out.write(requestData);
    //setup reader
    BufferedReader in = new     BufferedReader(new InputStreamReader(sock.getInputStream()));
    int c = 0;
    while (c != -1)
         c = in.read();
         responseData.append((char)c);
    sock.close();
    sock = null;
    }catch(Exception e){
                   System.out.println(e.getMessage());
              }finally{
                   if (sock != null)
                        System.out.println("Closing sock");
                        sock.close();
                        sock = null;
              return responseData.toString();
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    The problem is that the program waits indefinately in the while loop at the in.read()... it doesnot exit. I know i commented out the timeout of
    15 seconds cos that would help me exit... but i dont land up receiving any data and it just gets stuck there.
    I do not have any support from the Suppliers IT people so the last option was to check if i am doing things right... i really dont knw if i am doing sumthing worng here..
    So advise,
    Thanks :)
    manubhai

    Hey guys it works now - thanks for the byte[] idea..
    I do get the response now! however since the supplier does not return a -1 my while loop gets stuck. I have currently put a socket timeout to help break out - any clues to make this better????
    current code:
    try{
    sock.setSoTimeout(15000);     
    ByteArrayOutputStream ba = new ByteArrayOutputStream();
    ba.write(requestData.getBytes(),0,requestData.length());
    ba.writeTo(sock.getOutputStream());
    //setup reader
    BufferedReader in = new     BufferedReader(new InputStreamReader(sock.getInputStream()));
    int c = 0;
    while (c != -1)
    c = in.read();
    responseData.append((char)c);
    sock.close();
    sock = null;
    }catch(Exception e){
         System.out.println(e.getMessage());
    }

  • Desperately need Java network programming help!!!

    I need to make a Distributed File Sharing System (DFSS) using java language. The system should not make use of the central file server. The system should coordinate the concurrent access of files over the distributed environment. Caching may be used to enhance the system performance.
    It is basically network programming.
    Does any one have any idea how to make the DFSS. If you do please help!!!
    thank you in advance for you help
    cheers

    well, you're getting somewhere I guess. My original answer was intentionally vague because your original question was so vague. These fora are no good for asking questions like "how do I implement a distributed file system", they are good for asking things like "the following line(s) of code generate the following condition I didn't expect, rather I expected this condition, could someone tell me what is going on?" or something of similar specificity.
    So you are now asking how to, for instance, check to see if a text file is being shared. This is still too vague, but it's better than "how do I write a file sharing system". If you are feeling particularly industrious, go look at a project JXTA at http://www.jxta.org/ - it's open source, you can look at the code. Of course, if you're brand new, this might not help. In fact, not to discourage you, but if you're that new, this is not the project to be doing.
    Good Luck
    Lee

  • Looking into the possibilities of network programming

    Hi,
    One of my client is using a database application at their retail
    outlets. They have around 40 outlets located at various parts of
    the country. Now they want to set up a database at their Head Office
    and transfer all the data from the retail outlets to it. There are
    broadband internet connections available at all the outlets but
    there are chances of internet connectivity going down. The database
    we are using is PostgreSql 8.0
    Can this be achieved through a background process running at each
    retail outlet? Sending small packets of data from retail outlet to
    HO as soon as a transaction is persisited. There are Static IP
    available at HO.
    Can this be succesfully implimented? Has anybody done a similar
    work before? Is there any other alternative? Will Java Messaging
    or Network programming be helpful? Please help.
    Thank you.
    Vishal.

    The database product ought to be able to federate itself without you having to write any application code. If not, the best solution is to chagne DB vendor to one that does.

  • Network programs behind proxy

    I am a beginner in network programing,so i anyone could help me
    how till the program the proxy settings of my computer

    Try google
    http://www.google.co.uk/search?q=java+proxy+settings

  • Missing network programming on VOD?

    Normally VOD of network programming is a day behind.  It looks like the past 2 days aren't up yet- namely Life (NBC), CSI (CBS) and Grey's Anatomy (ABC).  Is it just me?  -- or is it a system-wide problem? 

    Here in So Cal we are missing Grey's, Lipstick Jungle, and Numb3rs as of Sunday.  Its starting to get irritating waiting for some of these shows to come up on VOD... whats going on Verizon?

  • Network programming - portability ?????

    Hi,
    I m developing a network game , using a multithread model. Do i need to hardcode the inet-address and port number of the server - i.e. SocketServer .
    If there is a better option ,then please tell.... because hardcoding the server inet address removes the portability aspect of my code.
    I am not using any feature of J2EE its purely network programming in J2SE.
    Thanks in advance

    Hi,
    I m developing a network game , using a multithread
    model. Do i need to hardcode the
    inet-address and port number of the
    server - i.e. SocketServer .Why would you think that? What would be special about parameters that you pass to networking methods vs. parameters that you pass to any other methods that the networking methods would know or care where they came from? Just like any other data your program uses, that data can be provided on the command line or in a properties file or by the preferences api or from a database or input from a user or or or or or....

  • Network programming tips

    I am new to network programming can anybody give me some tips on ways to optimize speed of an application that gets data via sockets over the network?
    You can assume its just a simple program where the client that gets continuous data feeds of sales amounts from the server and I want to make this program run faster.
    I would appreciate any ideas.
    Thanks!!

    Peter__Lawrey wrote:
    kci wrote:
    I am new to network programming can anybody give me some tips on ways to optimize speed of an application that gets data via sockets over the network?Don't worry about it. Your network is much slower than your CPU so it doesn't matter so much what you do in Java.
    I suggest you test your network to see what its latency and bandwidth is e.g. ping or transfer a large file and work out what you requirements are for latency and bandwidth.
    It very likely that you won't need to anything special in Java.
    You can assume its just a simple program where the client that gets continuous data feeds of sales amounts from the server and I want to make this program run faster.You should get a better understanding of the end to end process which needs to be faster and where you can make the most improvement. You are likely to find the GUI doesn't handle large tables or you are missing an index in your database.
    In Summary: determine where you can make the most difference and optimise that.
    I would appreciate any ideas. Actually there are loads of things you can do to make the network faster, but I would only do them if you actually need to.
    If you have done this analysis already what conclusions have you come to?Thanks a lot Peter!!
    All the posts in this thread have been helpful but yours definitely is the main direction I am looking for so I appreciate.
    Please if you can go a little further and help me with these issues....
    I am designing an application that is suppose to get real time data feeds over the network. Now as you said the network is slower than the CPU... But what if I am aiming for a latency of 5ms (just for the sake of discussion) but I ping the network and I see the latency is 10ms.
    Is there a way in this case you suggest I can optimize the network to reduce the latency.
    And no I haven't done the analysis yet. I am designing an application but I have never done this type of application so I am brainstorming now and you all have really helped out a lot so far!!

  • Network programming book

    Hi friends,
    I want to know about a book related to "Multicast and multi-homing" network programming in java.
    Thanks
    Ghouse

    I would suggest you look at Java Network Programming on Amazon.
    To repeat a previous posting, you cannot multicast over the internet.
    Multi-homing is and old approach to using a PC as a firewall. The PC has two network cards and passes packets back and forth based on filtering rules. Is this what you are looking for? Why wouldn't use use a firewall applicance which is probibly cheaper?

  • Advanced Java network programming

    I have been playing around with the various Server/Client tutorials not only on this site but many others for some time now. Whilst I have learnt a great deal I am now trying to further my knowledge.
    The problem is, there does not seem to be a great deal of information on the Web realting to the advanced network programming stuff. Obviously not having a network of my own I am now interested in learning various ideas using the Internet. Obviously not being a prat about it and port scanning other computers or anything like that.
    I was hoping someone reading this might have a suggestion about where to go next in my learning curve. Also if anyone could recommend any good sources of info for this type of stuff.
    I've currently got three telephone lines in, each line with a seperate Internet account set-up. What I want to do is have them all connected to the web at once and then attempt various things, such as connection, that type of stuff.
    Help really appreciated.
    Thanks,
    kP

    Maybe I'm catching the wrong vibe here, but it seems to me that you need to learn a bit about networking in general, before you worry about how it's all done in java. I would suggest a good basic computer networking text book. After you have good understanding of how different networks works, packet structure of the various common protocols, IP, TCP over IP and UDP over IP. I think the java code to implement it all will just fall into place. my AIM SN is SpinozaQ if you would like a book suggestion. I don't have any names going through my head right now.

  • Starting Network Programming

    Hi I am currently jumping into using java to make network applications. I am currently reading a book covering the basics of networking along with how tcp/ip works while working through a small suplemental book called "TCP/IP Sockets in Java for Programmers". I was wondering if any one had some suggestions on books to check out, or a better route to learning how to programming network applications.
    Thanks,
    Francesco DeSensi

    Don't jump into network programming first. Learn the basics of Java first (check the tutorials. You'll thank yourself.

  • Seeking overall guidance with network program causing OS lockup

    To start with I do realize that the problem is at source an OS one and therefore unresovable directly by me but I looking for guidance (mainly this is a good idea or a waste of time) in trying to isolate the problem and come up with a workaround if neccessary.
    The situation is this, I have a client and server Java program that has been running in a few places for about 18 months now. It's been running (both client and servers) on various Windows and Linux flavours during this time without incident (or at least incidents of this sort).
    I have one client though that is running Vista on the box the server is running on. And sometimes something is causing this box to totally freeze. This behaviour can fairly consistently be reproduced by making a request for data that is "large" (more on this in a moment) when the client makes this request the server freezes. Not just the server program (or not at all really) but the actual OS. Dead. It has to be physically rebooted.
    I have configured the sockets on both sides to use largish buffers (64K) and I have tried my best to follow the advice on various Socket performance, error handling and issue resolving present in Fundamental Networking in Java so I am fairly confident that while my program may have bugs there are no serious stupidities present in the networking side of it.
    Part of me just feels this is just a bad OS but another part of me feels I wish I knew what the problem was and if it's worth pursuing/tracking down. It's very hard to trace what's going on because as I mentioned the OS just dies when it happens but even though I know it's an OS issue (because at the end of the day there isn't a way for me to kill an OS like this through Java networking.. right?) the client isn't so convinced and somewhat understandbly so.
    So here are my options.
    - try and do more tracing as best I can to see what data is being sent/recieved when it dies.
    - make a test program to try and send data in amounts equal to the largest buffer size I use and see if I can get it to fail and where and at what point
    - something else I don't know involving some sort of traffic monitoring tool
    - stuff it. reintstall the OS and hope for the best.
    Any advice would be greatly appreciated.

    there isn't a way for me to kill an OS like this through Java networking.. right?Quite right. I have read about a JVM crash in ServerSocket.accept() somewhere else on these forums this morning: not a complete O/S failure though. There shouldn't even be a way to do that from C.
    Does the O/S just stall completely, or does it crash with something you can print here? A complete stall, or an O/S crash rather than a JVM crash, sounds more like hardware than software to me. I would certainly try replacing the NIC as well. If you're in the right kind of environment you could also get all the hardware diagnostics run and checked. I would also check for O/S and driver updates. If it's Windows I would check particularly for video card driver updates - for some reason these seem to be the flakiest parts of a Windows system.
    I suppose you could also try running it all with 32k buffers instead of 64k just to be doing something, and to at least eliminate that variable. But I think hardware, or else your final option, are probably the best bets.

Maybe you are looking for

  • Hi team can you assist me about this issue

    Hi team, just wanna tell you this problem if you can help me to fix this.. i buy a brand new video card, but this HP mt 3300 i3 is just a gift from my friend but its already slightly use. getting a problem on graphics card settings, the on board vga

  • This is a jo

    I had a crappy extreme nonsense x-fi that used to lock up and they said that a replacement would sort it out. So after farting about with sending it back, all that I get is the same pile of junk that STILL locks up. This is the biggest JOKE on earth.

  • Read table and binary search

    Hi all, I have a simple query regarding read int_tab with binary search. Why reading  internal table with binary search fails if it is sorted in descending order table must be sorted in ascending order? I check fo the algorithm of binary search, it d

  • What is a Data Socket? What is its use?

    What is a Data Socket? What is it used for? Regards, cooldude  Solved! Go to Solution.

  • App for billing, time management for contractor..

    Need an app to keep expenses, time billing by job or project for construction jobs.  Need to be able to attach notes--would like to be able to generate on the spot invoice for customers and email copy to home office.  Also, would like sketch pad with