|
hi all,,,
I have a mobile application project(server, client).
I want to connect between them using ip address write it in a client(mobile) and save this ip to a textfile...
the problem is... i can not access the file to read from it.
Thanks all
|
|
|
|
|
Ok, first off, the message subject is totally irrelevant to your problem, and if you have pulled through your "mobile" problem, all you have to do now is just open a System.IO.StreamReader and read the ip file.
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi, how do i use a proxy with a AxWebBrowser? I have codes like:
[DllImport("wininet.dll", SetLastError = true)]
private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength);
private struct INTERNET_PROXY_INFO
{
public int dwAccessType;
public IntPtr proxy;
public IntPtr proxyBypass;
};
public void SetProxyServer(string proxyServerAddress)
{
const int INTERNET_OPTION_PROXY = 38;
const int INTERNET_OPEN_TYPE_PROXY = 3;
const int INTERNET_OPEN_TYPE_DIRECT = 1;
INTERNET_PROXY_INFO struct_IPI;
// Filling in structure
if (proxyServerAddress == "")
{
// Clear any proxy settings and go "direct" to the Internet.
struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_DIRECT;
struct_IPI.proxy = IntPtr.Zero;
struct_IPI.proxyBypass = IntPtr.Zero;
}
else
{
// Assign the specified proxy server and port to access the Internet.
// This supports only anonymous proxy servers; support for authentication
// coming in the future.
struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
struct_IPI.proxy = Marshal.StringToHGlobalAnsi(proxyServerAddress);
struct_IPI.proxyBypass = Marshal.StringToHGlobalAnsi("local");
}
// Allocating memory
IntPtr intptrStruct = Marshal.AllocCoTaskMem(Marshal.SizeOf(struct_IPI));
// Converting structure to IntPtr
Marshal.StructureToPtr(struct_IPI, intptrStruct, true);
bool iReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, Marshal.SizeOf(struct_IPI));
}
then after i'll call the method passing in the ip address followed by wb2.nagivate("url).
but it doesn't show that I'm in a proxy when a "check ip" site is being loaded because it shows my original ip address..anyone wanna help out?
|
|
|
|
|
When u copy something from Internet be sure to check everything it writes in the article
Take a look to webBrowser.CreateObjRef on MSDN.
use RefreshIESettings("proxy:port") when u enter the link to the webbrowser. Look for Pandora flash browser for more directions on it.
modified on Sunday, November 9, 2008 7:08 AM
|
|
|
|
|
thanks for the reply..
I thought I should call SetProxyServer(123.132.123.123:8080) to set the proxy settings through my own defined method?
|
|
|
|
|
Should be SetProxyServer("123.132.123.123:8080") indeed ... i remained stucked with the original function name(that being RefreshIESettings).
|
|
|
|
|
How do you check whether you have successfully set the proxy?
|
|
|
|
|
Hi
i'm working in a C# client proyect, that client call SOAP methos from a PHP NUSOAP
this is the method using in PHP (nusoap)
require_once('lib/nusoap.php');
$server = new soap_server();
$ns='http://localhost/';
$server->configurewsdl('ApplicationServices',$ns);
$server->wsdl->schematargetnamespace=$ns;
$server->register('prueba',array('texto' => 'xsd:string'),array('return' => 'xsd:string'),$ns);
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA'])
? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
$server->service($POST_DATA);
function prueba($texto) {
$var1 = "Tu texto es: " . $texto;
return $var1;
}
exit();
?>
well, the soap code works fine. Now, the C# client
namespace soap1
{
[System.Web.Services.WebServiceBinding(Namespace = "http://localhost/", Name = "ApplicationServices")]
public class localhost1 : System.Web.Services.Protocols.SoapHttpClientProtocol
{
[System.Diagnostics.DebuggerStepThrough()]
public localhost1()
{
this.Url = "http://localhost/logeo.php";
}
[System.Web.Services.Protocols.SoapDocumentMethod("http://localhost/logeo.php",
RequestNamespace = "http://localhost/",
ResponseNamespace = "http://localhost/",
Use = System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string prueba(string texto)
{
object[] resultado = this.Invoke("prueba", new object [] { texto });
return(Convert.ToString(resultado[0]));
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
localhost1 app1 = new localhost1();
string s = app1.prueba("pato");
MessageBox.Show(s);
}
}
}
now, the c# code here, works fine and they detect my php method
¿the problem?
well, in that line
string s = app1.prueba("pato");
the "s" variable has in blank, no result, no value return
i test the SOAP server code in a SOAP client code and works fine, return a string value, but in this c#, no string value returns. why??
NOTE: Sorry for my BAD english
|
|
|
|
|
hello all,
actually i am working on richtextbox control in window application.
i have a problem in font class. because i want to show rtf file paragraph in para for <\p>,
for bold paragrpah<\b>,
For ITalic Paragrph,<\I>.
so, how here i am use font class to generate such tag with every paragrph.
my code is here,plz help me ...???
richTextBox1.LoadFile(filepath,RichTextBoxStreamType.RichText);
string inputstring = richTextBox1.Text;
StringBuilder sb =newStringBuilder(inputstring);
//string xx = inputstring;
//string yy = xx.Replace("", "");
sb.Insert(0, "<p>");
//string yy = xx.Replace("", "");
//sb.Replace("<p>", "");
//int num = 0;
// sb.Replace("<p>"
//Random rand = new Random(3);
string rt = "" ;
for (int i = 0; i < 10; i++)
{
rt = i.ToString();
}
//sb.Insert(0, "<p local_id = P-" + rt + ">");
sb.Replace("\n", "</p>" + "\n" + "<p>");
//sb.Replace("<p local_id = P-" + rt + ">" +"</p>", "");
//sb.Append("</p>");
//sb.Replace("<p local_id = P-" + rt + ">" + "</p>", "");
sb.Replace("\n\n", "\n");
sb.Replace("\n\n", "\n");
sb.Replace("\n\n", "\n");
sb.Replace("\n\n", "\n");
sb.Replace("\n\n", "\n");
sb.Replace("\n\n", "\n");
int p=0;
string xx = sb.ToString ();
int ppara = 0;
ppara = xx.IndexOf("<p>", 0);
while (ppara!= -1)
{
p = p+1;
string f1 = Convert.ToString(p);
f1.ToString().PadLeft(3);
xx = xx.Remove(ppara, 3);
xx = xx.Insert(ppara, "<p local-id=\"p-" + p + "\">");
ppara = xx.IndexOf("<p>", ppara+3);
}
richTextBox1.Text = xx.ToString();
}
//}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
|
|
|
|
|
use RichTextBox.Select(int start, int lengthofselection) and then apply the style you want to selection using RichTextBox.SelectionFont property
|
|
|
|
|
thanks for ur warm response...
when applied this its not working prperly...
code is:-
while (ppara <= xx.Length)
{
int postspace = xx.IndexOf("", 0);
if (postspace != -1)
{
string word = xx.Substring(x, postspace);
richText.Select(x, postspace);
richTextBox1.SelectionFont.Bold;
xx = xx.Insert(ppara, "");
}
}
help me for code.....
|
|
|
|
|
int postspace = xx.IndexOf("", 0); is equivalent to int postspace = xx.IndexOf(String.Empty, 0); which doesn't make too much sense ... if you're looking for the first occurence of a space use int postspace = xx.IndexOf(" ", 0);
|
|
|
|
|
hello,
here i want to read every character while space. when new word come again then he read continue..if any character is bold and italic he show in richtextbox with sequence no...
i am new in C# dot net.so plz provide me some specific code related to it.
|
|
|
|
|
What I want to do is be able to stick a form to the top, left, right or bottom of the screen - all the way across. I found this: http://www.codeproject.com/KB/dialog/FormDocker.aspx but I don't know how I would use a VB class in a C# project, plus I don't want to have to install the VB component of VS2008 just to compile a class.
|
|
|
|
|
My.Computer.Screen.WorkingArea.[Width, Height, Top, Bottom] and use them according to your needs.
|
|
|
|
|
I found this: http://www.codeproject.com/KB/shell/csdoesshell3.aspx?msg=2799390#xx2799390xx but the window disapeers when I press Windows+D, how could I catch the Windows+D key sequence?
|
|
|
|
|
You don't want to catch Windows+D, that's a standard keyboard-shortcut to "Show Desktop". You wouldn't be happy if some programmer decided to hijack ctrl-alt-del, now would you? Even if you succeeded, I could always right-click the taskbar and select "Minimize All" and the effect would be the same. The good news is that Microsoft has made it hard to catch the key-sequence.
The bad news is that you don't even have to catch that key.. Set your window to be the TopMost one, and restore your form in the OnMinimize-handler.
HTH,
|
|
|
|
|
I'm now have a problem of coding the shift scheduling or workforce scheduling, firstly i think i need a help on coding the chromosome representation for my schedule. My schedule is using 2D array method where my row is for the employee and column is the day (Monday, Tuesday,....). The element that stated in my schedule is the employee shift either (Day, Afternoon, or Night). Can anyone help me? It doesn't matter what programming language but preferable Java , or VB or C++. Thanks a lot. Hope to get feedback from you all, I really need the help.
|
|
|
|
|
Hi there does anybody know any methods that check what colour a cirtain pixel is?
It'd also be nice if you told me any way i could get a cirtain pixel clicked too (by any means necisery....)
thanks alot for any help
|
|
|
|
|
Hi,
depends on the circumstances. If you have a Bitmap, then GetPixel(x,y) returns the color
at that location. There are ways to turn (part of) your screen into a bitmap, search for
"screen capture".
|
|
|
|
|
Luc is right in both of your points, unless you meant the location of the pixel clicked, in that case use the mouse event e.Location
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
I'm developing an application in which multiple clients exchange data on a TCP link with a server using a custom protocol.
I've chosen the asynchronous approach to implement the server: i.e. my application listens for incoming connection with BeginAccept , and accepts them with EndAccept , receives data with BeginReceive/EndReceive and so on. I also keep a list of connected client state information, so that the users of my class can read several info about the clients (IP address, connection state etc.)
Now, I'm implementing several methods to forcibly disconnect a client, and to shutdown the whole server (disconnect all the clients and release server resources). Unfortunately, simply closeing the clients + server sockets does not work because the pending operations (EndAccept etc.) fail with various kind of exceptions (NullReference , ObjectDisposed etc.)
Is there a correct way to forcibly shutdown connections?
Regards,
Andrea
|
|
|
|
|
Hi Andrea,
I was hoping that Shutdown would be thread-safe. Obviously not, so you'll have to implement some control synchronization yourself.
You can do this with a ReaderWriterLock - or preferably ReaderWriterLockSlim, if you are targeting .NET 3.5. Something like this:
private volatile bool quit = false;
private ReaderWriterLock rwl = new ReaderWriterLock();
Socket clientSocket = null;
rwl.AcquireReaderLock(-1);
try
{
if ( quit ) return;
clientSocket = serverSocket.EndAccept(state);
}
finally
{
rwl.ReleaseReaderLock();
}
rwl.AcquireWriterLock(-1);
try
{
quit = true;
foreach ( var client in clientList )
{
client.Socket.Shutdown();
client.Socket.Dispose();
}
}
finally
{
rwl.ReleaseWriterLock();
}
Does that make sense?
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
As usual you save my day Nick! I'm currently refactoring my server code for better maintainability, as soon as possible I'll try your suggestion and let you know.
Thanks!
Andrea
|
|
|
|
|
You're welcome.
Metal76 wrote: and let you know
Please do - this is quite interesting
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|