473,378 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Standard network method

Hi
I'd like a way of communicating over a network that doesn't rely on
vendor-specific libraries, preferably that will work on both windows and
linux (the ideal solution would be one that compiles on windows and linux,
but the absolute ideal one would be one that also enables windows to
communicate *with* linux in realtime, but that's a pipe dream as yet...)
Nothing too fancy, the amounts of data won't be great. Just open a
connection on a specific port, send some data down it, close. And receive
from the other end.

i.e. is there a standard library function for it...? I'm thinking along the
lines of fopen(), fread(), ..... , is there an f_tcp() ?

Can be either in C or C++.
Nov 14 '05 #1
17 1854
use (TCP-)sockets.

Bonj wrote:
Hi
I'd like a way of communicating over a network that doesn't rely on
vendor-specific libraries, preferably that will work on both windows and
linux (the ideal solution would be one that compiles on windows and linux,
but the absolute ideal one would be one that also enables windows to
communicate *with* linux in realtime, but that's a pipe dream as yet...)
Nothing too fancy, the amounts of data won't be great. Just open a
connection on a specific port, send some data down it, close. And receive
from the other end.

i.e. is there a standard library function for it...? I'm thinking along
the lines of fopen(), fread(), ..... , is there an f_tcp() ?

Can be either in C or C++.


Nov 14 '05 #2
Bonj wrote:
Hi
I'd like a way of communicating over a network that doesn't rely on
vendor-specific libraries,
Then you have a problem.
preferably that will work on both windows and
linux (the ideal solution would be one that compiles on windows and linux,
but the absolute ideal one would be one that also enables windows to
communicate *with* linux in realtime, but that's a pipe dream as yet...)
Nothing too fancy, the amounts of data won't be great. Just open a
connection on a specific port, send some data down it, close. And receive
from the other end.

i.e. is there a standard library function for it...? I'm thinking along the
lines of fopen(), fread(), ..... , is there an f_tcp() ?

Can be either in C or C++.


Nothing like that exists in C. You either need to find a third party
library ported to all the systems you are interested in or write your own.

<OT>
There is a lot of commonality between Windows and *nix, since MS based
their TCP/IP library on BSD Sockets. So writing some thin wrappers is
not that difficult. However, how you do networking is not on topic here,
so ask for details in networking and/or system specific groups.
</OT>

Any C++ answers are off topic in comp.lang.c, so please take it off if
posting a C++ answer.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 14 '05 #3
Bonj wrote:
i.e. is there a standard library function for it...? I'm thinking along the lines of fopen(), fread(), ..... , is there an f_tcp() ?

Can be either in C or C++.


There is no standard library support for sockets in either C or C++.
Boost does not support sockets yet either.

There are some sockets libraries that claim to be portable to many
platforms, but they are not standard.

--
Dave O'Hearn

Nov 14 '05 #4
Bonj wrote on 31/12/04 :
I'd like a way of communicating over a network that doesn't rely on
You are completely off-topic ont both newsgroups.
vendor-specific libraries,
Write your own.
preferably that will work on both windows and
linux (the ideal solution would be one that compiles on windows and linux,
BSD Sockets and Winsock2 are very similar.
but the absolute ideal one would be one that also enables windows to
communicate *with* linux in realtime, but that's a pipe dream as yet...)
There is no reason for a network (IP, for example) not to support
mac+linux+windows or anyelse servers/clients... Zillions of working
solutions are running around the world probably for a 10th of years...
Nothing too fancy, the amounts of data won't be great. Just open a connection
on a specific port, send some data down it, close. And receive from the other
end.

i.e. is there a standard library function for it...? I'm thinking along the
lines of fopen(), fread(), ..... , is there an f_tcp() ?


No. I think there is a kind of a portable wrapper for networking, but I
can't recall the name. Search the net. Google is your friend.

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"Clearly your code does not meet the original spec."
"You are sentenced to 30 lashes with a wet noodle."
-- Jerry Coffin in a.l.c.c++

Nov 14 '05 #5
Florian Quetting <qu******@email.de> scribbled the following
on comp.lang.c:
Bonj wrote:
Hi
I'd like a way of communicating over a network that doesn't rely on
vendor-specific libraries, preferably that will work on both windows and
linux (the ideal solution would be one that compiles on windows and linux,
but the absolute ideal one would be one that also enables windows to
communicate *with* linux in realtime, but that's a pipe dream as yet...)
Nothing too fancy, the amounts of data won't be great. Just open a
connection on a specific port, send some data down it, close. And receive
from the other end.

i.e. is there a standard library function for it...? I'm thinking along
the lines of fopen(), fread(), ..... , is there an f_tcp() ?

Can be either in C or C++.

use (TCP-)sockets.


As the OP seems to have been asking how to use TCP-sockets, your answer
is kind of circular.
Anyway, the C language has no support for any sort of networking
whatsoever, TCP-sockets or otherwise. Actually C predates TCP by quite
many years.
Please don't give off-topic answers on comp.lang.c.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"We sorcerers don't like to eat our words, so to say."
- Sparrowhawk
Nov 14 '05 #6
In article <11**********************@c13g2000cwb.googlegroups .com>,
Dave O'Hearn <da******@pobox.com> wrote:
Bonj wrote:
i.e. is there a standard library function for it...? I'm thinking
along the lines of fopen(), fread(), ..... , is there an f_tcp() ?

Can be either in C or C++.


There is no standard library support for sockets in either C or C++.
Boost does not support sockets yet either.


What is "Boost" ?

Nov 14 '05 #7
Kenny McCormack wrote on 31/12/04 :
What is "Boost" ?


A C++ thing...

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"C is a sharp tool"

Nov 14 '05 #8
The past inherited, the future encapsulated.

"Kenny McCormack" <ga*****@yin.interaccess.com> wrote in message
news:cr**********@yin.interaccess.com...
In article <11**********************@c13g2000cwb.googlegroups .com>,
Dave O'Hearn <da******@pobox.com> wrote:
Bonj wrote:
i.e. is there a standard library function for it...? I'm thinking
along the lines of fopen(), fread(), ..... , is there an f_tcp() ?

Can be either in C or C++.


There is no standard library support for sockets in either C or C++.
Boost does not support sockets yet either.


What is "Boost" ?

Nov 14 '05 #9
"Kenny McCormack" <ga*****@yin.interaccess.com> wrote in message
news:cr**********@yin.interaccess.com...
In article <11**********************@c13g2000cwb.googlegroups .com>,
Dave O'Hearn <da******@pobox.com> wrote:
Bonj wrote:
i.e. is there a standard library function for it...? I'm thinking
along the lines of fopen(), fread(), ..... , is there an f_tcp() ?

Can be either in C or C++.


There is no standard library support for sockets in either C or C++.
Boost does not support sockets yet either.


What is "Boost" ?


It's a library of utilities for C++, much of which
is slated to be included in the next revision of
the standard.

See www.boost.org

-Mike
Nov 14 '05 #10
BTW please do not top-post

AD ;-)

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:Q3*****************@newsread1.news.pas.earthl ink.net...
"Kenny McCormack" <ga*****@yin.interaccess.com> wrote in message
news:cr**********@yin.interaccess.com...
In article <11**********************@c13g2000cwb.googlegroups .com>,
Dave O'Hearn <da******@pobox.com> wrote:
>Bonj wrote:
>> i.e. is there a standard library function for it...? I'm thinking
>>along the lines of fopen(), fread(), ..... , is there an f_tcp() ?
>>
>> Can be either in C or C++.
>
>There is no standard library support for sockets in either C or C++.
>Boost does not support sockets yet either.


What is "Boost" ?


It's a library of utilities for C++, much of which
is slated to be included in the next revision of
the standard.

See www.boost.org

-Mike

Nov 14 '05 #11
I am not sure what you mean. But a TCP/IP protocol can meet your
requirement. And by the way, I think a open source library "ACE" ( Adaptive
communication envirement), which can be found in www.cs.wustl.edu/~schmidt/
, can be used directly.

"Bonj" <a@b.com> дÈëÓʼþ news:33*************@individual.net...
Hi
I'd like a way of communicating over a network that doesn't rely on
vendor-specific libraries, preferably that will work on both windows and
linux (the ideal solution would be one that compiles on windows and linux,
but the absolute ideal one would be one that also enables windows to
communicate *with* linux in realtime, but that's a pipe dream as yet...)
Nothing too fancy, the amounts of data won't be great. Just open a
connection on a specific port, send some data down it, close. And receive
from the other end.

i.e. is there a standard library function for it...? I'm thinking along the lines of fopen(), fread(), ..... , is there an f_tcp() ?

Can be either in C or C++.

Nov 14 '05 #12
>> use (TCP-)sockets.

As the OP seems to have been asking how to use TCP-sockets, your answer
is kind of circular.
Thanks, this is precisely correct.
Anyway, the C language has no support for any sort of networking
whatsoever, TCP-sockets or otherwise. Actually C predates TCP by quite
many years.


I'm not bothered about whether it's actually defined as part of the C
standard. As long as it's "standard enough" to work on windows and linux.
Nov 14 '05 #13

"Emmanuel Delahaye" <em***@YOURBRAnoos.fr> wrote in message
news:mn***********************@YOURBRAnoos.fr...
Bonj wrote on 31/12/04 :
I'd like a way of communicating over a network that doesn't rely on
You are completely off-topic ont both newsgroups.


So what's the correct newsgroup to post requesting something in C, that
works on windows and linux then?
Write your own.


Where do I start?
Nov 14 '05 #14

"Bonj" <a@b.com> schrieb im Newsbeitrag
news:33*************@individual.net...
Hi
I'd like a way of communicating over a network that doesn't rely on
vendor-specific libraries, preferably that will work on both windows
and linux (the ideal solution would be one that compiles on windows
and linux, but the absolute ideal one would be one that also enables
windows to communicate *with* linux in realtime, but that's a pipe
dream as yet...)
Nothing too fancy, the amounts of data won't be great. Just open a
connection on a specific port, send some data down it, close. And
receive from the other end.

i.e. is there a standard library function for it...? I'm thinking
along the lines of fopen(), fread(), ..... , is there an f_tcp() ?

Can be either in C or C++.


You can download the source code for HawkNL - a cross platform
networking library - based on socks:
http://www.hawksoft.com/hawknl/
I think it's very good, though it's not maintained much anymore I
think.

also, from Alex Vinokur:
C++ Stram Compatible TCP/IP Sockets:
http://sourceforge.net/projects/cpp-sockets/
http://alexvn.freeservers.com/s1/sock.html

HTH,
Gernot
Nov 14 '05 #15
Bonj wrote:

"Emmanuel Delahaye" <em***@YOURBRAnoos.fr> wrote in message
news:mn***********************@YOURBRAnoos.fr...
Bonj wrote on 31/12/04 :
I'd like a way of communicating over a network that doesn't rely on
You are completely off-topic ont both newsgroups.


So what's the correct newsgroup to post requesting something in C, that
works on windows and linux then?


comp.lang.c is the right place to ask questions about portable C
programming. Unfortunately, network programming can't be done in
a way that is sufficiently portable to justify its discussion in
comp.lang.c. Nevertheless, your second question (below) is
topical, in my opinion, so I'll try to answer it.
Write your own.


Where do I start?


Begin by learning how to write networking programs in Linux,
if you don't already know how to do this.

Continue by learning how to write networking programs in
Windows, if you don't already know how to do this.

Finally, abstract the non-portable parts of your programs
into a library, in such a way that you can keep your
application portable. Think of your library as a layer
between your application and the OS-specific aspects
of networking.

For example, under Windows, you need to start the
networking interface using an OS-specific call. Under
Linux, you don't. So you could write a routine
something like this:

/* start_networking() - Windows version */
int start_networking(P p)
{
/* insert Windows networking startup code here */

return 0 if it worked, or a non-zero value otherwise.
}

/* start_networking() - Linux version */
int start_networking(P p)
{
return 0;
}

In your .lib, you'll use the first version. In
your .a or .so, you'll use the second. In both
cases, your application code will look something
like this:

int got_a_network = start_networking(params);
if(got_a_network)
{
do stuff here
}

C++ fans might have a different way of doing
this, but this way will work in both languages.

The point is that, whilst the body of the
library routines will differ across platforms,
the interface stays the same, which means that
your application code itself need not change.

It's not trivial, but it's not rocket science either.
Nov 14 '05 #16
Apologies for following up to my own article...

infobahn wrote:

<snip>
int got_a_network = start_networking(params);
if(got_a_network)
{
do stuff here
}


This should read:

int network_error = start_networking(params);
if(network_error == 0)
{
do stuff here
}

Oops.
Nov 14 '05 #17
On Mon, 3 Jan 2005 09:11:28 -0000, in comp.lang.c , "Bonj" <a@b.com> wrote:

(someone said)
Anyway, the C language has no support for any sort of networking
whatsoever, TCP-sockets or otherwise. Actually C predates TCP by quite
many years.


I'm not bothered about whether it's actually defined as part of the C
standard. As long as it's "standard enough" to work on windows and linux.


Then you need to ask in the right group - comp.unix.programming tends to
handle sockets questions I think, and with some care the answers can be
applied to other OSen too.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 14 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Alex Ang | last post by:
I have written the following VBScript program. It is stored into a file "map_drive.vbs". It successfully mapped to a network drive \\server1\data. Dim WshNetwork Set WshNetwork =...
3
by: Robert Tarantino | last post by:
Hello, I am trying to find a way to create a scheduled task or service that will copy my local profile folders under "Documents and settings" to a network drive. This would allow me to restore...
15
by: Bonj | last post by:
Hi I'd like a way of communicating over a network that doesn't rely on vendor-specific libraries, preferably that will work on both windows and linux (the ideal solution would be one that compiles...
5
by: Nirosh | last post by:
Hi All, Can any one suggest me a best way to do this .. I have a thrid party tool "EXE" that we need to use with our web service to manipulate some complex XML files, which reside in a...
8
by: BJ | last post by:
Problem: How can I code up a client side process to detect if the network is available? Synopsis: I am writing ASP.NET input forms for a Panasonic Tuff book. The users will be walking around...
0
by: basuritta | last post by:
I am trying to add a SQL2000 subscriptor to a SQL2005 publisher and distributor using the Management Studio. I'm using a non-standard port in both ends, but I have set the port for the TCP/IP...
2
by: =?Utf-8?B?ZGdjb29wZXI=?= | last post by:
When I get a list of drives using the Directory.GetLogicalDrives(), it gives me all drives including disconnected network drives. When I attempt to use Directory.GetDirectories() on a disconnected...
10
by: John Nagle | last post by:
Here are three network-related exceptions. These were caught by "except" with no exception type, because none of the more specific exceptions matched. This is what a traceback produced: 1....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.