الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كيف التعامل مع البروكسي ؟

مغلق
بدأه helwanif في 7 أغسطس 2004 · 8 رد · 901 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته

عندي برنامج تشات client - server بس المشكلة لما يكون في proxy مايمكن تشغيله ،،

هذه المشكلة تتكرر معي عندما أتعامل مع URL Connecrtion وذلك لوجود البروكسي

هي هناك من يعرف كيفية التعامل مع البروكسي بيحث تكون هذه البرامج تعمل حتى خلال الانترنت وراء proxy

في انتظار الرد مع التحية

#2

آه هذه المشكلة عقدتني كثير و اكيد برنامج التشات تطبيق يعني يعمل على جهازك و جهازك بدوره يتصل بالنت عن طريق بروكسي ... مو هيك؟؟

في موضوع قديم جدا سوف ابحث عنه و اعطيك الملخص ثواني..

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

#3

هذا هو الكود... اي خدمة ثانية انا جاهز

System.getProperties().put( "proxySet", "true" ); 
System.getProperties().put( "proxyHost", proxy address); 
System.getProperties().put( "proxyPort", proxy port);

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

#4

this is similar code

but it include the user name and password

note that it si part of a big project ...

so i just cut that method ... it can work alone

// method to set the properity-----------------------------------------------
   private void setProperity(boolean usePort)
   {
     if(usePort)
     {
       properity = System.getProperties();
       properity.put("proxySet", "true"); // <== set to true
       properity.put("proxyHost", Proxy); //<== add the proxy
       properity.put("proxyPort", Integer.toString(PortNumber)); //<== change PortNumber to your port


       String pw = UserName + ":" + PassWord; //<== insert the userName and the Password
       String epw = (new BASE64Encoder()).encode(pw.getBytes());
       urlcon.setRequestProperty("Proxy-Authorization", "Basic " + epw);
     }// end if
     else
     {
       properity.put("proxySet",  "false");
       System.setProperties(properity);
     }// end else
   }// end method setProperity

hope itwill help you

and yes ... the import classes

import java.net.URL;
import java.net.URLConnection;
import java.net.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.DataOutputStream;
import java.io.DataInputStream;
import java.util.Properties;
import com.sun.javaws.util.BASE64Encoder;
#5

شكر اخي المبرمج ولكن لا اظن ان بحاجة الى باسورد لان بروكسي الذي يعاني منه هو لدولة ما و عادة لا يضعون له كلمة سر لكل واحد!!!

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

#6
اقتباس
عادة لا يضعون له كلمة سر لكل واحد!!!

icon1.gificon1.gificon1.gificon6.gif

#7

فعلا متل ماذكر الأخ رامي : البروكسي بدون باسوورد لإنو تابع للدولة

أنا رح جرب الطريقة وإن شاء الله بيمشي الحال

#8

my object of insert the userName and Password

since there are some proxies need user names and passwords

i.e. company's Proxies ... ISP proxies...etc

the object is show you how to use the UserName ANd Password if you need it in the future ...

^_^

#9

شكرا إخواني على الرد ، بس الطريقة ماتنفع ، جربتها ومامشي الحال

برنامجي يعتمد على فتح socket بين السرفر وبين الكلاينت ، جربتها على شبكة محلية LAN واشتغل بس لما حاولت عن طريق الانترنت مامشي الحال

هل يوجد طريقة لجعل Socket يتعامل مع البروكسي ؟ وإذا كانت الإجابة بلا فكيف يمكن تجاوز هذه المشكلة

هذا الموضوع مغلق.

مواضيع مشابهة