Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help C#/C++ I Need help!
#1
Hi guys, i have small problem: my cpp program doesnt not work (dont play sound)
C++ Code
  1. #include <Windows.h>
  2. #include <iostream>
  3. #include <MMsystem.h>
  4. #pragma comment(lib,"winmm.lib")
  5. #pragma comment(lib,"dsound.lib")
  6. using namespace std;
  7. int main()
  8. {
  9. int a = 5;
  10. int b;
  11. cin >>b;
  12. if(b<= a)
  13. {
  14.  
  15. PlaySound(TEXT("windowsxp.wav"),NULL,SND_SYNC);
  16.  
  17. }
  18. system("pause");
  19. return 0;
  20. }
OMA
[Image: One_Man_Army_Bag_render_MW2.PNG]
Reply

#2
It's the most easiest task ever.
Simple networking. I can give c++/c example, but I forgot this stuff in c#. It's P2P ( peer to peer ) connection.
I can give you a tip: use tcp.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#3
(12-14-2014, 21:11)Nekochan Wrote: It's the most easiest task ever.
Simple networking. I can give c++/c example, but I forgot this stuff in c#. It's P2P ( peer to peer ) connection.
I can give you a tip: use tcp.
Example please
OMA
[Image: One_Man_Army_Bag_render_MW2.PNG]
Reply

#4
Well, as I said I don't remember some stuff from C#, but here you go, pseudocode.
Code:
// Create a tcp stuff.
int mPort = 1082; // Taking lower than 1024 will give you an errors, these are system-precached.
TcpListener mServerSocket = new TcpListener( mPort );
TcpClient mClientSocket = default( TcpClient );
mServerSocket .Start(); // Start server.

Console.WriteLine("Server started.");
while( true ) {
                mClientSocket = mServerSocket.AcceptTcpClient(); // Wait for connections.

                byte[] recvBytes = new byte[16384];
                string clientData = null;

                NetworkStream networkStream = mClientSocket.GetStream(); // Read client data.
                networkStream.Read( recvBytes , 0, (int)mClientSocket.ReceiveBufferSize );

                clientData = System.Text.Encoding.ASCII.GetString( recvBytes ); // Create UTF8/ASCII string.

                Console.WriteLine( "Someone joined." );

                ParseCommands( clientData ); // Here you parse your commands from client.
}

For client, use the same method, but remove 'start' and use 'connect'
Code:
mClientSocket.Connect(" *IPADDRESS* ",  1082 );

and then use 'Send' with commands you wish.  eg: "Send("playsound Soundname")". and parse it in ParseCommands function. ( Split string ).
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#5
(12-14-2014, 21:57)Nekochan Wrote: Well, as I said I don't remember some stuff from C#, but here you go, pseudocode.
Code:
// Create a tcp stuff.
int mPort = 1082; // Taking lower than 1024 will give you an errors, these are system-precached.
TcpListener mServerSocket = new TcpListener( mPort );
TcpClient mClientSocket = default( TcpClient );
mServerSocket .Start(); // Start server.

Console.WriteLine("Server started.");
while( true ) {
                mClientSocket = mServerSocket.AcceptTcpClient(); // Wait for connections.

                byte[] recvBytes = new byte[16384];
                string clientData = null;

                NetworkStream networkStream = mClientSocket.GetStream(); // Read client data.
                networkStream.Read( recvBytes , 0, (int)mClientSocket.ReceiveBufferSize );

                clientData = System.Text.Encoding.ASCII.GetString( recvBytes ); // Create UTF8/ASCII string.

                Console.WriteLine( "Someone joined." );

                ParseCommands( clientData ); // Here you parse your commands from client.
}

For client, use the same method, but remove 'start' and use 'connect'
Code:
mClientSocket.Connect(" *IPADDRESS* ",  1082 );

and then use 'Send' with commands you wish.  eg: "Send("playsound Soundname")". and parse it in ParseCommands function. ( Split string ).

Thanks you Heart , I understand C++ code :-) .
OMA
[Image: One_Man_Army_Bag_render_MW2.PNG]
Reply

#6
You can help me?
How me make endless loop on C#?
I am need in check some events in every 10 minute?
OMA
[Image: One_Man_Army_Bag_render_MW2.PNG]
Reply

#7
dont click on button/ ets events
OMA
[Image: One_Man_Army_Bag_render_MW2.PNG]
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.