Re: Urgent TCP/IP C Programming

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/12/2014 07:59 AM, Jyotishmaan Ray issued this missive:

Hello All Fedora Lonux TCP/IP experts,

Hi!!

This is an urgent issue, which needs to be resolved at the earliest time!!!

Given platform : Fedora Linux OS(free open source), Version 16, with GCC
(GNU compiler) and 2 C language programs, where one is jc.c which is a
client program, and  jsvc.c , which is a server program.

Fedora 16 is long, LONG dead (like three years dead). The current
release is Fedora 20, with Fedora 21 being released soon.

Problem: Both the programs compiled with warnings, which I had ignored.
Most importantly, the server program is failing to bind the process to
its port.

Unless you understand what the warnings are, that's not a good thing.
This is really beyond the scope of this mailing list, but I will try to
answer you.

I doubt this has anything to do with the compile warnings, but unless
the bind() is called with the port set to SO_REUSEADDR, you can only
have one program listening on the port. You can see if something else
is on the port by running

	netstat -lpn | grep :XXX

as the root user, where XXX is the port you're interested in, e.g.:

	netstat -lpn | grep :22

would show you what program is listening on port 22 (SSH):

	[root@prophead ~]# netstat -lpn | grep :22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1528/sshd tcp6 0 0 :::22 :::* LISTEN 1528/sshd

As you can see, a program called "sshd" (with the process ID of 1528) is listening on port 22 on both IPV4 and IPV6.

Reasons, which could not be explored yet, and not known to my knowledge.

Issues:

(1) On my system, in fedora linux environment, I failed to create two
terminals, for executing two programs as a cient and and another as a
server.

Can we not have two terminals at a time in one fedora linux environment.

Of course you can. You're not clear as to what you mean by "terminal"--
do you mean console windows, serial-port terminals or virtual consoles?

(2) Kindly let me know why the server program is failing at the point of
bind(...) function call.

What is wrong wioth my parameters, or anything else if I have missed ??

Kindly let me know!!

(3) Is it necessary to execute both the client and server programs in
two different systems in a LAN.

If they're using the same port, then either they have to be on different
IP addresses (e.g. using an alias) or on separate machines.

If they absolutely must be on the same machine (e.g. for testing
purposes), then I'd suggest you have both programs open the port in
SO_REUSEADDR mode. Here's an (untested) code snippet:

	int sock;
	int onoff = 1;
	sock = socket(AF_INET, SOCK_STREAM, 0);
	setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
	    (char *)&onoff, sizeof(onoff)) {
	bind(.....);

I had earlier run both the processes in one system, however long time
back, hence I forgot the exact hardware specfication ( that had in the
system). But I remember it was DEC System, having all the GUI interface,
in which I could have as many terminals as I wanted.

Note : In the given environment, of Linux fedora operating system, I can
nt have more than one terminal ..? Any ideas, why there is such a
limitation..? Is it that because of the stand along installation etc.

There is no such limitation. It depends on which desktop you're running
(Gnome, KDE, XFCE, etc.). In the start menu (or Applications or whatever
it's called in your desktop), open the "Terminal emulator" application.

Kindly reply me all the answers, with server program binding well  and
exceutes such that, it goes into listening mode and the client program
connects to it and finally sends a message to it before closing the
connection.

As I said before, this really goes beyond what we deal with on this
list. You need to get a C programmer to answer this stuff in detail on
a different list.
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer, AllDigital    ricks@xxxxxxxxxxxxxx -
- AIM/Skype: therps2        ICQ: 22643734            Yahoo: origrps2 -
-                                                                    -
-      "Microsoft is a cross between The Borg and the Ferengi.       -
-  Unfortunately they use Borg to do their marketing and Ferengi to  -
-               do their programming."  -- Simon Slavin              -
----------------------------------------------------------------------
--
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org




[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux