473,327 Members | 1,952 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,327 software developers and data experts.

socket and namespace question

Hi,
I am having a name collision between a library call and a class I've
created.

My class is called "socket", it abstracts a TCP socket.

In my constructors for my class, I am calling the socket library function
socket():

m_mySocket = socket(AF_INET,SOCK_STREAM,0)

My compiler is compaining "no overloaded function takes 3 parameters" while
clearly the socket library function does.

Is there a standard way to steer the compiler towards the correct function?

TIA,

ed
Jul 22 '05 #1
2 3986

"Ed Fair" <ed*****@mindspring.com> wrote in message
news:tc*******************@newsread1.news.atl.eart hlink.net...
Hi,
I am having a name collision between a library call and a class I've
created.

My class is called "socket", it abstracts a TCP socket.

In my constructors for my class, I am calling the socket library function
socket():

m_mySocket = socket(AF_INET,SOCK_STREAM,0)

My compiler is compaining "no overloaded function takes 3 parameters" while clearly the socket library function does.

Is there a standard way to steer the compiler towards the correct function?
TIA,


I would suggest that you follow the common convention for application code
and capitalise your class names, i.e. Socket. But if you don't want to do
that then you could use a namespace.

namespace networking
{
class socket
{
socket()
{
::socket(AF_INET,SOCK_STREAM,0);
}
};
}

The use of :: indicates that you want the socket library function, which is
in the global namespace, not your socket class (whose full name is
networking::socket).

john
Jul 22 '05 #2
On Thu, 04 Mar 2004 18:04:09 GMT in comp.lang.c++, "Ed Fair"
<ed*****@mindspring.com> was alleged to have written:
My class is called "socket", it abstracts a TCP socket.

In my constructors for my class, I am calling the socket library function
socket():

m_mySocket = socket(AF_INET,SOCK_STREAM,0)

My compiler is compaining "no overloaded function takes 3 parameters" while


m_mySocket = ::socket(AF_INET,SOCK_STREAM,0)

Jul 22 '05 #3

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

Similar topics

5
by: Russell Warren | last post by:
Does anyone know the scope of the socket.setdefaulttimeout call? Is it a cross-process/system setting or does it stay local in the application in which it is called? I've been testing this and...
6
by: Michel Hardy | last post by:
Hello, does anyone know how to use the Socket.IOControl method to set the keep alive message? I already have the SIO_KEEPALIVE_VALS value and structure, but how do I pass it to the IOControl...
1
by: Dan Kelley | last post by:
I have 2 projects - 1 Winform project that sends Udp messages using the UdpClient class when a button is clicked, and a Console application that listens for these Udp messages. If I try to use...
6
by: Steve Richter | last post by:
I dont get the point of socket.BeginReceive and socket.EndReceive. As I understand it, BeginReceive will start a 2nd thread, call the ReceiveCallback delegate in the 2nd thread, then block until...
3
by: BuddyWork | last post by:
Hello, Could someone please explain why the Socket.Send is slow to send to the same process it sending from. Eg. Process1 calls Socket.Send which sends to the same IP address and port, the...
0
by: Buddy Home | last post by:
There is two examples of code. Example 1. Send and Receive within the same process. Put this code in a console app called SendAndReceive and run the code. using System; using...
6
by: Sean | last post by:
Hi Everyone, My apologies for a somewhat dump question but I am really stuck. I have been working on this code for two days straight I am dont know what is wrong with it. when I run the code, All...
4
by: shofu_au | last post by:
Hi Group, A question about threads and asynchronous TCP sockets. In the attached code, even if the host TCP server is not running my code reports that the connection has been established. ...
8
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi all, I am new to .net technologies. ASP.NET supports socket programming like send/receive in c or c++? I am developing web-site application in asp.net and code behind is Visual C#. In...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.