CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: Chatting

  1. #1
    Join Date
    Mar 2004
    Location
    India
    Posts
    276

    Chatting

    Hi all,
    hope everybody is dng fine....i have a doubt actually i am trying to simulate chatting between two machnies within same LAN using MFC.its like i will get the computer name to which the user want to chat.Now after this is there any method to get the IP address of this machine and then establish communication with it?
    plz help me

    Thanks in advance
    Poorni
    Life is like riding a bicycle To keep ur Balance u have to keep riding.

  2. #2
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    [Moved thread]

  3. #3
    Join Date
    Jan 2004
    Location
    Punjab, India
    Posts
    113
    Check out the following articles.


    Amit

  4. #4
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    To answer your direct question, I think gethostbyname will do what you asked.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  5. #5
    Join Date
    Feb 2003
    Location
    Bangalore, India
    Posts
    1,354
    Please keep similar questions in the same thread.


    You can use the API gethostbyname() to get the ip.

    To establish connection, you can use socket() and related functions (WinSock programming). However you have to do some learning before you start to write. Codes and tutorials are there in the web. You can search this forum itself. A good site ishere.
    Even if our suggestions didn't help, please post the answer once you find it. We took the effort to help you, please return it to others.

    * While posting code sections please use CODE tags
    * Please check the codeguru FAQ and do a little search to see if your question have been answered before.
    * Like a post, Rate The Post
    * I blog: Network programming, Bible

    I do all things thru CHRIST who strengthens me

  6. #6
    Join Date
    Sep 2002
    Location
    Belarus - Tirol, Austria
    Posts
    647

    Re: connection

    If it's considered to use tcp/ip communication, U should look at the following functions:
    socket(), connect(), send(), etc.
    For UNIX system read man pages for them.
    For Win, there's a good overview here: http://www.tangentsoft.net/wskfaq/
    in additon to documentation in MSDN (serach for winsock).

    There's a lot of other tutorials via the Web, just search.
    "UNIX is simple; it just takes a genius to understand its simplicity!"

  7. #7
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    [Merged threads]

  8. #8
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

  9. #9
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125
    Content deleted by author. Not appropriate after threads were merged.
    Last edited by TheCPUWizard; April 13th, 2004 at 04:45 AM.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  10. #10
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    [Merged threads]



    Poorni, please stop creating new threads for the same question. Thank you very much.

  11. #11
    Join Date
    Mar 2004
    Location
    India
    Posts
    276

    Connection

    hi all,
    Thanks for the info u all have given me for the previous messages.Now the chatting application i have tried is working fine in one machine i.e.. the same application can act as server and also client.I first have to run the server and made to wait in Listen mode ,then i will run the second instance of the program which acts as client and it communicates with the server which is listening and then data can be exchanged between the applications .Now the same application with server running in one machine and client in another machine is not working i.e i couldnt establish connection between the two.Now Can anyone tell me the port number thru which we can communicate with another machine.I am using port no.4000.Plz help me

    Thanks in advance,
    Poorni
    Life is like riding a bicycle To keep ur Balance u have to keep riding.

  12. #12
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Well...there are some ports in the lower range (< 1025 or similar) which you should not use. However, 4000 should not make a problem. Nevertheless, just to make sure...the number must be the same for the server and client...

  13. #13
    Join Date
    Mar 2004
    Location
    India
    Posts
    276

    thanks

    hi all,
    Thanks for all of ur help.Now my chat program is working.Expecting the same kind of reply from u people in future also.

    Thanks
    Poorni
    Life is like riding a bicycle To keep ur Balance u have to keep riding.

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