LinuxQuestions.org
Help answer threads with 0 replies.
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 10-26-2005, 02:00 PM   #1
jcchenz
LQ Newbie
 
Registered: Oct 2005
Posts: 2

Rep: Reputation: 0
Does anyone know how to write a date server in C for Red Hat linux?


hi all!

I'm a newbie to Linux!! I'm currently using Red Hat 2.4.28 and I need to convert a Java program of Date Server into C. Does anyone know how to do this? or is there a site i can go to that can teach me how to? I'm Totally lost!! I will type the java program below.. so if anyone could help me, i would be really grateful! Or at least give me a direction on what i should do!

import java.net.*
import java.io.*

public class DateServer
{
public static void main(String[] args) {
try{
ServerSocket sock = new ServerSocket (6013);
//now listen for connections
while(true){
Socket client = sock.accept();

PrintWriter pout = new
PrintWriter(client.getOutputStream(), true);

// write teh Date to the socket
pout.println(new java.util.Date() .toString());

/close the socket and resume
//listening for connections
client.close();
}
}
catch (IOException ioe) {
System.err.println(ioe);
}
}
}


thanks for any help anyone can provide me!

JC
 
Old 10-26-2005, 03:49 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
Again, this is apparently homework. LinuxQuestions.org is not here to do homework for you, and this looks like a very basic example of the use of a tcp socket. get a C book, learn C. If you have specific issues about, for example, the use of certain functions etc... then we'll be happy to help if we can.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Red Hat 9 up to date with Promise FastTrack emerrf Linux - Security 1 04-20-2005 11:27 AM
Red Hat 9 server can't write PHP script, problem in httpd.conf file? x_menno_x Linux - Newbie 27 06-29-2004 04:44 PM
How to configure Red Hat Linux as a server gschrade Red Hat 3 10-29-2003 12:32 PM
Red Hat Linux 7.3 as a Mail Server harperonline Linux - Networking 2 03-12-2003 04:34 AM
red hat 8 and date,time ronss Linux - Distributions 2 12-04-2002 01:20 AM

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

All times are GMT -5. The time now is 01:42 PM.

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