CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2009
    Posts
    21

    can i use same ip and port in 2 application

    hi, i m new to socket programming, if suppose i created application(xp) with some port and ip for send and receive and this app is running. and then if i create 2nd app can i use same ip and port using in 1st app. or if only port is same in both app, or if only ip is same in both app, then it will work. i want to know in both cases (TCP and UDP)

  2. #2
    Join Date
    Feb 2009
    Location
    Portland, OR
    Posts
    1,488

    Re: can i use same ip and port in 2 application

    Depending on the implementation, say for TCP when you attempt to bind a socket when it's already bound it may produce an error if SO_EXCLUSIVEADDRUSE flag was used. But, even if you succeed in opening your sockets with the same ports in two or more processes, besides an obvious need for some sort of synchronization, it poses a big security risk, because an attacker can technically do the same with your program. Read more here:
    http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx

    The question is why do you need to use the same port for two applications?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured