Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 06-28-2004, 06:53 AM   #1 (permalink)
iwanttolearnc
Registered User
 
iwanttolearnc's Avatar
 
Join Date: Jun 2004
Posts: 11
iwanttolearnc is on a distinguished road
please bind my socket

the usual practice is to use connect() for client and let the os select the port ..etc. but i have two network cards and hence two ip addresses. i want to have control over which ip my communication occurs. how can it be done.

can i try a bind() to the ip and port i desire and follow it with a connect() or is there some other way
iwanttolearnc is offline   Reply With Quote
Old 07-06-2004, 04:53 PM   #2 (permalink)
snaphat
Registered User
 
Join Date: Jul 2004
Posts: 1
snaphat is on a distinguished road
sockaddr_in service;
service.sin_family = AF_INET;
service.sin_addr.s_addr=inet_addr("192.168.0.4");
service.sin_port=htons(995);

//You would specify the IP address where it is in the example

[EDIT]Actually I realize my post doesn't apply.
snaphat is offline   Reply With Quote
Old 07-07-2004, 12:45 PM   #3 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
the BSD socket interface (or their derivative, Winsock) does not allow you to choose the outgoing IP or interface for connect(). It is up to the OS to choose the best route. There may be system-specific ways of doing this (perhaps some ioctl supported on your OS), but there is no general solution.
joe_bruin is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counter-Strike and Socket programming Redline PHP 7 10-25-2004 03:04 PM
Winsock problem.. oops Standard C, C++ 2 06-25-2002 03:09 PM


All times are GMT -8. The time now is 11:12 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting