otroligafredde
asked on
an easy winsock question
I have what I think is an easy question about
the winsock control. I don't know what to write
to connect. I want to connect to port 1001 and
the computers name I want to connect to is
"FREDRIK" I have tried
to write:
winsock1.connect("FREDRIK" ,1001);
but I don't get it to work. Please help me.
Thanks in advance.
the winsock control. I don't know what to write
to connect. I want to connect to port 1001 and
the computers name I want to connect to is
"FREDRIK" I have tried
to write:
winsock1.connect("FREDRIK"
but I don't get it to work. Please help me.
Thanks in advance.
ASKER
I'm using visual studio 6.0
and winsock1 is the variable for the winsock
control. it's really m_client.
and winsock1 is the variable for the winsock
control. it's really m_client.
So you are using CAsyncSocket class?
ASKER
No I'm not using CAsyncSocket class.
Should I?
I don't really know how to do this. I just
inserted the winsockcontrol in my project
and now I'm trying to use it with the functions
that comes with it. Listen, Accept, OnConnectionRequest
and so on....
Is there more I need to know?
Should I?
I don't really know how to do this. I just
inserted the winsockcontrol in my project
and now I'm trying to use it with the functions
that comes with it. Listen, Accept, OnConnectionRequest
and so on....
Is there more I need to know?
Ok, sorry I'm a bit slow this morning ...
Yes there is more you should know!
I think the best way is to read the chapters
Windows Sockets: Background
Windows Sockets: Sequence of Operations
Windows Sockets: Socket Notifications
Windows Sockets: Ports and Socket Addresses
.
> but I don't get it to work.
What is the exact behaviour?
Your server is listening?
Yes there is more you should know!
I think the best way is to read the chapters
Windows Sockets: Background
Windows Sockets: Sequence of Operations
Windows Sockets: Socket Notifications
Windows Sockets: Ports and Socket Addresses
.
> but I don't get it to work.
What is the exact behaviour?
Your server is listening?
ASKER
I think that my server application is listening
but I can't tell for sure, cause I can't get my client
application to work.
I have used the winsock control in visual basic before
so I know how it works. it's just that it's much more complicated
in vc++.
But if I want to read the chapters that you wrote about
should I look in any special book? My msdn library doesn't
work.
the problem I have is that it's something wrong with the parameters that I'm passing to the Connect function.
It wants a const &var or something, I don't know what to write.
I don't know if this comment made my question any clearer.
but I can't tell for sure, cause I can't get my client
application to work.
I have used the winsock control in visual basic before
so I know how it works. it's just that it's much more complicated
in vc++.
But if I want to read the chapters that you wrote about
should I look in any special book? My msdn library doesn't
work.
the problem I have is that it's something wrong with the parameters that I'm passing to the Connect function.
It wants a const &var or something, I don't know what to write.
I don't know if this comment made my question any clearer.
Ok,
> the problem I have is that it's something wrong with the
> parameters that I'm passing to the Connect function.
that means you can not complie your client?
Did you try other ports?
Which kind of protocol do you use (in case of TCP/IP did you try
the whole name of you server: e.g. "FREDRIK.domain.com")?
> I think that my server application is listening
> but I can't tell for sure, cause I can't get my client
> application to work.
So you are not sure, whether the problem is in the server or the
client!?
> the problem I have is that it's something wrong with the
> parameters that I'm passing to the Connect function.
that means you can not complie your client?
Did you try other ports?
Which kind of protocol do you use (in case of TCP/IP did you try
the whole name of you server: e.g. "FREDRIK.domain.com")?
> I think that my server application is listening
> but I can't tell for sure, cause I can't get my client
> application to work.
So you are not sure, whether the problem is in the server or the
client!?
I'm really slow this day!
Socket port 1001 is invalid!
Ports < 1024 are reserved for privileged processes (e.g. root).
Try a port > 1024.
Socket port 1001 is invalid!
Ports < 1024 are reserved for privileged processes (e.g. root).
Try a port > 1024.
And if you're using MFC (which you obviously do use) try asking in the MFC programming area instead of the C++ area. You'll usually get more/better responses there.
ASKER
I don't think it's the port number that's causing
the problem. I have changed it now by the way.
It's the way I'm calling the Connect function thats
wrong.
I get a compile error when I call it.
I call it like this:
m_klient.Connect(FREDRIK, 1025);
and I have tried it like this:
m_klient.Connect("FREDRIK" , 1025);
but it wants a 'const struct tagVARIANT' instead of FREDRIK or "FREDRIK"
Do you know what I do wrong?
Thanks in advance!
the problem. I have changed it now by the way.
It's the way I'm calling the Connect function thats
wrong.
I get a compile error when I call it.
I call it like this:
m_klient.Connect(FREDRIK, 1025);
and I have tried it like this:
m_klient.Connect("FREDRIK"
but it wants a 'const struct tagVARIANT' instead of FREDRIK or "FREDRIK"
Do you know what I do wrong?
Thanks in advance!
ASKER
Yes I do use TCP/IP
Try
COleVariant myVarinat( "FREDRIK" );
.
m_klient.Connect(myVarinat , 1025);
.
COleVariant myVarinat( "FREDRIK" );
.
m_klient.Connect(myVarinat
.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In addition to what I have already submitted, if you want to use a computer name located somewhere on the network, you can place the computer name in the hosts file(NT) along with its ip address, but in the sockets connect function use the server's IP address for the server(i.e. FREDRIK's ip address). If FREDRIK is the same machine as the client use "localhost" as the name.
What is *winsock1*?