Help C#/C++ I Need help!
#1
Hi guys, i have small problem: my cpp program doesnt not work (dont play sound)
Code:
#include <Windows.h> #include <iostream> #include <MMsystem.h> #pragma comment(lib,"winmm.lib") #pragma comment(lib,"dsound.lib") using namespace std; int main() { int a = 5; int b; cin >>b; if(b<= a) { PlaySound(TEXT("windowsxp.wav"),NULL,SND_SYNC); } system("pause"); return 0; }
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-2026 Melroy van den Berg.