Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


DirectPlay FindHosts [c#]

This topic is 5368 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is regarding Peer to Peer connections, there is no host but another instance of the app is trying to connect, enumerating all the possible host in a subnet. so how can I tell that the FindHosts has finish enumeration and display the message "FAIL TO FIND VALID HOST". I know I should use CancelAsyncOperation to cancel the FindHosts request, but I dont know when I should use it, any advice? Thanks I have 2 buttons in the form, button 1 will set the parameter host to true and button 2 will set it to false
private Peer connection = null;

private void InitializeDirectPlay(bool host)
    connection = new Peer();

    connection.FindHostResponse += new FindHostResponseEventHandler(OnFindHost);
        connection.Host(desc, deviceAddress);
        connection.FindHosts(desc, null, deviceAddress, null, 0, 0, 0, FindHostsFlags.OkToQueryForAddressing);

private void OnFindHost(object sender,FindHostResponseEventArgs e)
        connected = true;
        string foundsession = String.Format("Found Session {0}), trying to connect.", e.Message.ApplicationDescription.SessionName);

        this.BeginInvoke(new AddTextCallBack(AddText), new object[]{foundsession});

	((Peer)sender).Connect( e.Message.ApplicationDescription, e.Message.AddressSender, e.Message.AddressDevice,null,ConnectFlags.OkToQueryForAddressing);
[edited by - wingcom on March 30, 2004 10:52:23 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!