Jump to content
xisto Community

khalilov

Members
  • Content Count

    281
  • Joined

  • Last visited

  • Days Won

    1

khalilov last won the day on December 20 2013

khalilov had the most liked content!

About khalilov

  • Rank
    Super Member
  • Birthday 01/01/1990

Contact Methods

  • Website URL
    http://

Profile Information

  • Gender
    Male
  • Location
    Atlantis
  1. At the beginning I was going to make my P2P chat project using pure C/C++ (black console). But we were informed that we can use visual C. So I have a question // adad.cpp : main project file.#include "stdafx.h"#include "Form1.h"using namespace adad;[STAThreadAttribute]int main(array<System::String ^> ^args){ // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // Create the main window and run it Application::Run(gcnew Form1()); Form1 a; return 0;} How do I make Form1 a appear? putting it in the Application::Run command gives the following error Error 1 error C2665: 'System::Windows::Forms::Application::Run' : none of the 3 overloads could convert all the argument types c:\Users\pc\Documents\Visual Studio 2005\Projects\adad\adad\adad.cpp 18 Also an advice, I haven't used visual before so what best type would suit a P2P chat (similar to IRC) project? I am going with Windows Forms Application. My basic idea is: Main page: Username/Password/Login button/Signup button Sub pages: Login successful / Registration forum etc... Key pages: Listing all active accounts and active chats. When you click on chat/account you start chatting ( a special form for chatting is shown) Is such a thing possible in one application? Note: This is a big project, so I can't use any 3rd party or any premade libraries that provide with the functions for visual P2P chat, I have to make everything. And so far, it's going well 8)
  2. yes both are on same computer, and when I remov the threading, or the recv function in particular from the server script it works without erros
  3. Client /* client.c - code for example client program that uses TCP */#ifndef unix#define WIN32#include <windows.h>#include <winsock.h>#else#define closesocket close#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <netdb.h>#endif#pragma comment(lib,"Ws2_32.lib")#include <stdio.h>#include <string.h>// link with Ws2_32.lib#pragma comment(lib,"Ws2_32.lib")#define PROTOPORT 5193 /* default protocol port number */extern int errno;//char localhost[] = "localhost"; /* default host name */char localhost[] = "127.0.0.1"; /* default host name *//*------------------------------------------------------------------------ * Program: client * * Purpose: allocate a socket, connect to a server, and print all output * * Syntax: client [ host [port] ] * * host - name of a computer on which server is executing * port - protocol port number server is using * * Note: Both arguments are optional. If no host name is specified, * the client uses "localhost"; if no protocol port is * specified, the client uses the default given by PROTOPORT. * *------------------------------------------------------------------------ */ char records[100][256]; int recordi=0; char message[100]; int messagei=0;void receivedata(void* sd){while(1) { int n,i; char buf[256]; n = recv(sd, buf, sizeof(buf), 0); while (n > 0) { flushall(); n = recv(sd, buf, sizeof(buf), 0); sprintf(records[recordi],"%s",buf); system("CLS"); for(i=0;i<=recordi;i++) printf("%s",records[i]); printf("Message: %s",message); recordi++; } puts(""); } /* Close the socket. */ closesocket(sd);}int main(int argc, char* argv[]){ int i; struct hostent *ptrh; /* pointer to a host table entry */ struct protoent *ptrp; /* pointer to a protocol table entry */ struct sockaddr_in sad; /* structure to hold an IP address */ int sd; /* socket descriptor */ int port; /* protocol port number */ char *host; /* pointer to host name */ int n; /* number of characters read */ char buf[256]; /* buffer for data from the server */#ifdef WIN32 WSADATA wsaData; WSAStartup(0x0101, &wsaData);#endif memset((char *)&sad,0,sizeof(sad)); /* clear sockaddr structure */ sad.sin_family = AF_INET; /* set family to Internet */ /* Check command-line argument for protocol port and extract */ /* port number if one is specified. Otherwise, use the default */ /* port value given by constant PROTOPORT */ if (argc > 2) { /* if protocol port specified */ port = atoi(argv[2]); /* convert to binary */ } else { port = PROTOPORT; /* use default port number */ } if (port > 0) /* test for legal value */ sad.sin_port = htons((u_short)port); else { /* print error message and exit */ fprintf(stderr,"bad port number %s\n",argv[2]); getchar(); exit(1); } /* Check host argument and assign host name. */ if (argc > 1) { host = argv[1]; /* if host argument specified */ } else { host = localhost; } /* Convert host name to equivalent IP address and copy to sad. */ ptrh = gethostbyname(host); if ( ((char *)ptrh) == NULL ) { fprintf(stderr,"invalid host: %s\n", host); getchar(); exit(1); } memcpy(&sad.sin_addr, ptrh->h_addr, ptrh->h_length); /* Map TCP transport protocol name to protocol number. */ if ( ((int)(ptrp = getprotobyname("tcp"))) == 0) { fprintf(stderr, "cannot map \"tcp\" to protocol number"); getchar(); exit(1); } /* Create a socket. */ sd = socket(PF_INET, SOCK_STREAM, ptrp->p_proto); if (sd < 0) { fprintf(stderr, "socket creation failed\n"); getchar(); exit(1); } /* Connect the socket to the specified server. */ if (connect(sd, (struct sockaddr *)&sad, sizeof(sad)) < 0) { fprintf(stderr,"connect failed\n"); getchar(); exit(1); } printf("Connected to %s at port %d\n",host,sd); _beginthread(receivedata, 0, (void*)sd); while(1) { message[messagei]=getch(); messagei++; message[messagei]='\0'; printf("%c",message[messagei-1]);} /* Repeatedly read data from socket and write to user's screen. */ /* Terminate the client program gracefully. */ } Server #include<winsock2.h>#include<winsock.h>#include <stdio.h>#include <windows.h> //Not necessary if using MFC#include <TChar.h> //..#include <assert.h>#include<conio.h>// link with Ws2_32.lib#pragma comment(lib,"Ws2_32.lib")#include<process.h>#include <ws2tcpip.h>#include <stdlib.h> #define PROTOPORT 5193 /* default protocol port number */#define QLEN 6 int visits = 0; /* counts client connections *//*------------------------------------------------------------------------ * Program: server * * Purpose: allocate a socket and then repeatedly execute the following: * (1) wait for the next connection from a client * (2) send a short message to the client * (3) close the connection * (4) go back to step (1) * * Syntax: server [ port ] * * port - protocol port number to use * * Note: The port argument is optional. If no port is specified, * the server uses the default given by PROTOPORT. * *------------------------------------------------------------------------ */ char message[100]; char buf[256]; int i; char c; char records[100][256]; int recordi=0; int messagei=0; void serverThread(void* sd){ while(1) { int n,i; char buf[256]; n = recv(sd, buf, sizeof(buf), 0); //while (n > 0) { flushall(); //n = recv(sd, buf, sizeof(buf), 0); sprintf(records[recordi],"%s",buf); system("CLS"); for(i=0;i<=recordi;i++) printf("%s",records[i]); printf("Message: %s",message); recordi++; //} puts(""); } // closesocket(sd);}int main(int argc, char* argv[]){ struct hostent *ptrh; /* pointer to a host table entry */ struct protoent *ptrp; /* pointer to a protocol table entry */ struct sockaddr_in sad; /* structure to hold server's address */ struct sockaddr_in cad; /* structure to hold client's address */ int sdmain,sd, sd2,sd3; /* socket descriptors */ int port; /* protocol port number */ int alen; /* length of address */ char buf[256]; /* buffer for string the server sends */#ifdef WIN32 WSADATA wsaData; WSAStartup(0x0101, &wsaData);#endif memset((char *)&sad,0,sizeof(sad)); /* clear sockaddr structure */ sad.sin_family = AF_INET; /* set family to Internet */ sad.sin_addr.s_addr = INADDR_ANY; /* set the local IP address */ /* Check command-line argument for protocol port and extract */ /* port number if one is specified. Otherwise, use the default */ /* port value given by constant PROTOPORT */ if (argc > 1) { /* if argument specified */ port = atoi(argv[1]); /* convert argument to binary */ } else { port = PROTOPORT; /* use default port number */ } if (port > 0) /* test for illegal value */ sad.sin_port = htons((u_short)port); else { /* print error message and exit */ fprintf(stderr,"bad port number %s\n",argv[1]); exit(1); } /* Map TCP transport protocol name to protocol number */ if ( ((int)(ptrp = getprotobyname("tcp"))) == 0) { fprintf(stderr, "cannot map \"tcp\" to protocol number"); exit(1); } /* Create a socket */ sdmain = socket(PF_INET, SOCK_STREAM, ptrp->p_proto); sd=sdmain; if (sd < 0) { fprintf(stderr, "socket creation failed\n"); exit(1); } /* Bind a local address to the socket */ if (bind(sd, (struct sockaddr *)&sad, sizeof(sad)) < 0) { fprintf(stderr,"bind failed\n"); exit(1); } /* Specify size of request queue */ if (listen(sd, QLEN) < 0) { fprintf(stderr,"listen failed\n"); exit(1); } /* Main server loop - accept and handle requests */ while (1) { alen = sizeof(cad); if ( (sd2=accept(sd, 0, 0)) < 0) { fprintf(stderr, "accept failed\n"); exit(1); } // create a thread printf("Connection established on socket %d \n",sd2);_beginthread(serverThread, 0, (void*)sd2); while(1){ gets(message); sprintf(buf,"Server: %s\n", message); //send(sd2,buf,sizeof(buf),0); for(i=strlen(buf);i<sizeof(buf);i++) buf[i]='\0'; send(sd2, buf, sizeof(buf), 0); } closesocket(sd2); printf("Connection terminated on %d\n Waiting for new connections",sd2); getch(); }} Error Error 1 error C2664: 'recv' : cannot convert parameter 1 from 'void *' to 'SOCKET' c:\users\pc\documents\visual studio 2005\projects\a\a\server.cpp 43 I don't understand, the server coding is similar to the client coding yet the server gives an error but the client doesnt. It works perfectly. If you remove the threading and the serverThread from server only it will work. The declaration is similar on both server and client scripts so I don't get it 8/ Note: This might not be the best way to make this script, I am working on a small P2P chat using C,C++ sockets and I am still in the basis. But I encountered this error. I really hate C errors, I've wasted like two hours on changing variables and googeling with no result. The compiling was done using Visual studio 2005 8.0.5
  4. I have a mini chat on my website and i want to avoid stripping inputs from html and php tags so i made all inputs appear inside textareas. Here is a test piece of code: <?php$originaltext="x<br>s<br>s<br>s<br>s<br>s<br>s<br>s<br>s<br>s<br>s<br>s";$fixedtext = str_replace("<br>", "\n", $originaltext); //turn the <br>s into new lines inside textareasecho "<textarea style=\"background:black;color:white;border:0px;overflow:visible;\" >".$fixedtext."</textarea>";?>the overflow has no effect on google chrome or firefox but has effect on internet explorer, how do i make it work on other browsers? on a side question can i strip the effect (effect not the syntax) from divisions? i can deal with them better than text areas. meaning if you put <table><tr><td>s</td></tr></table> as in input inside chat it will appear the same, no effect.. just like if it is shown inside a text area.
  5. For the first option:So your saying i have no choice but to include about 1000 line in every file while i only need about 50 of them?I am just wondering how much CPU processing power is consumed when you define functions and don't use them, does the server just ignore function definitions and go back to some of those definitions if they are used? meaning including lets say 10,000 lines of code of defining functions does it have no effect if i don't use any of those functions?As for the second option; modifying servers' source code... can you give more details on that?
  6. I am creating a game and for simplicity i am making every possible query a function, ex instead of $result=mysql_query("SELECT* FROM tablename WHERE columnname=$variable");if($result=mysql_fetch_array($result)) { commands } else { commands } i make a function and it becomes $x=getinfo($variable)if($x) { commands } else {commands} A lot easier to debug for errors and more eye friendly. However the way it is going there are going to be many functions, 50~100 functions. All will be stored in a file named functions.php, this file will hit ~1000 lines. So including this file in every page on my web would be annoying since i only need 1 or 2 functions tops (about 50 lines of predefined syntax) and i end up adding 1000 lines and prolonging the execution time of a fairly simple script. I'd be defining functions i wont use at the time. Dividing functions.php into functions1.php, functions2.php.... and including one/some of them depending on the current script in execution might be a solution but i rather not. My question is that is there a way i can integrate these functions into the server so that they become like standard predefined functions (like echo ,mysql_fetch_array....)? That way i can call these functions without including anything or worrying about wasted CPU. thanks in advance
  7. the acount is suspendedlol just noticed that this id old srry
  8. Wow its been a while since my last post, its good to be back. I've worked hard on some javascript animation to work along side my game to add more quality. The basic idea for the javascript to take effect is a user presses on something (example: an item), that click calls an ajax function which loads a certain division. Inside that newly loaded content that is viewed in that division there would be javascript functions that would show these animations. However everything loads except the java functions, even the simple alert and document.write dont show. I googled the problem and i couldn't understand the solution. Here is a small example of the problem: test.php <script>//Browser Support Codefunction fun(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay1 = document.getElementById('elem'); ajaxDisplay1.innerHTML = ajaxRequest.responseText; } } ajaxRequest.open("GET", "testing2.php", true); ajaxRequest.send(null); }</script><div id=elem>s</div><input type=submit onClick=java script:fun()> testing2.php <script>document.write('s')</script> when you click the submit button the division is reloaded but nothing is shown, my guess is that the java function document.write did not process, if you u redo it with anything thats not a function it would work perfectly. This is problem makes dozens of javascripting hours a waste if not solved. Please help =)
  9. I am using both frames and fields to design my website, and i need help with something. <html><head><title>Page</title></head><frameset cols="25%,75%"><frame scrolling='auto' src="1.html><frame scrolling='yes' src="2.html></frameset></html>the 25% frame is a menu , and the 75% page is the main page. The menu has many options and thus sometimes needs scrolling, the main page naturally needs scrolling. What i want to happen is have one scroll bar for both of them, as if both frames were just one. I know this can be achieved by using fields instead of frames and position them using CSS but i'v already designed most of the web. Can someone also please tell me whats the difference between having scrolling set to 'auto' and 'yes' because they seem the same to me. Appreciated.
  10. I don't need alot of space so Hotmail does it for me, my internet is slow a bit so i suffer from the java or flash thing. Although its annoying to block all those spam sources ...
  11. hm... thats a tough one. if you're gona do it with C language i think you need to make several files each containing certain key words. First file fill it with bad words , second with jokes, etc..whenever a user inputs something every word is compared with the records, if it is found in the bad words files the loop is broken and a response like "didn't your mother tell you not to say that" is printed or something, and if someone enters lets say "sad", a response like "Don't be sad" or "I'll make you feel better" and then a joke is printed out. Its gona be hard, i suggest doing it with something other than C language, but iam still a newbie in programing =)
  12. The purpose of my website is to make money online, iam over 18 and i have a bank acount along with a credit card. The problem is i live in lebanon which is not on paypal list which is annoying since before i noticed it i sent a small amount of $ to my paypal acount. Any ways i succesfully added my visa card number to paypal but it requires verification with a cost, the visa card i have is from a lebanese bank and they told me that it can be used on the internet (my friend used a similar one) so there is no problem their. Its just i chose another country which doesn't have a branch of my bank. Will i be able to recieve payments through the visa to my acount or is it not possible for me (in lebanon) to be paid via paypal.Also, i registered on moneybookers.com and it has lebanon on its list, does anyone know if i can recieve payments through it to lebanon cuz it also charges a card verification fee.A clear anwser would be really appreciated =), and a similar services which deals with lebanon will be appreciated even more =)Also to whome i send a mail if i wanted to contact moneybookers staff i can't find it and the preanwsered questions aren't what i need.
  13. I installed wamp on my usb and when i execute it from there the picture that is similar to a speedometer apears for less than a second and disappears. There is no problem with the computer since when i run it from C:/wamp it works normally. Is it possible to run wamp from a usb portable device or is that not possible?
  14. Iam currently busy with my university and i cann't log in neither here nor at Xisto - Support alot. I stopped all my packages, iam wondering is there a risk of being deleted due to inactivity at either sites cuz i have 10+$ in my acount =)
  15. if i remember correctly when i ordered my pack it had 1 database in it, now it has five, when did this hapen and is there an extra cost?also i haven't been working on my site for like 1 month or so so iam thinking of stopping my service for now till i can continue. Iam thinking of downloading everything and stoping my package. How do i downlaod everytying?(databases/files/scripts...)
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.